Results 1 to 2 of 2

Thread: Setting Focus On Textbox Upon Form Loads

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Question Setting Focus On Textbox Upon Form Loads

    Hi,

    May I know how do i go about setting focus on a particular text box upon the loading of the form? I.E. Page Load Event... Is this possible in ASP.Net too? Or only in VB Windows Form only...

    Thanks for your help.
    ______________________________________

    Warmest Regards,

    Lex
    ______________________________________



    :|: Don't Mess With The Predator :|:

  2. #2
    Lively Member
    Join Date
    Aug 2004
    Posts
    94

    Re: Setting Focus On Textbox Upon Form Loads

    I your page_load you call the sub SetFocusControl fe. SetFocusControl(Page, Me.UserName.ID.ToString)

    and of course the sub :

    Public Sub SetFocusControl(ByRef Pagina As System.Web.UI.Page, ByVal ControlName As String)
    ' character 34 = "

    Dim script As String = _
    "<script language=" + Chr(34) + "javascript" + Chr(34) _
    + ">" + _
    " var control = document.getElementById(" + Chr(34) + _
    ControlName + Chr(34) + ");" & _
    " if( control != null ){control.select();}" & _
    "</script>"


    Pagina.RegisterStartupScript("Focus", script)

    End Sub


    This works fine for me, except when I push the Tab he jumps to the address bar So if you find the reason, let me know !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width