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.
Printable View
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.
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 :cry: So if you find the reason, let me know !