set focus at end of text in textbox

Discussion in 'ASP .Net Web Controls' started by ton, Mar 17, 2008.

  1. ton

    ton Guest

    Hi,

    I'm using Ajax to seach direct in a gridview. It works fine. I even keep the
    focus on the input text box. Here is my code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    TextBox2.Attributes.Add("onKeyUp", "javascript:__doPostBack('" +
    TextBox2.ID + "','')")
    TextBox2.Focus() 'the initial focus in de load event of the page



    and when firing the postback after the key up I got this function working:

    Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
    System.EventArgs)
    DbWebGrid2.ShowGrid(dbRecordNET.Session.dbTableNum.cTableClient, , ,
    "where name like '%" & TextBox2.Text & "%'") 'shows the clients using the
    filter
    ScriptManager1.SetFocus(TextBox2) 'this keeps the focus, BUT ON THE
    FIRST CHARACTER


    End Sub
    How can I keep the cursor to the end of the textbox, so user can keep on
    typing to refine their search

    thanks

    Ton
    ton, Mar 17, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Olav Tollefsen

    Set focus and cursor at end of text?

    Olav Tollefsen, Jan 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    35,561
    Mohammad A. Samara
    Jan 20, 2004
  2. ton
    Replies:
    1
    Views:
    1,101
  3. Replies:
    1
    Views:
    106
    kaeli
    Jan 20, 2004
  4. Replies:
    2
    Views:
    323
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    299
Loading...

Share This Page