ASP.NET doesn’t provide a built-in method for giving a control the input focus when the page loads. In fact, you can assign the TabIndex properties to controls on a page, but you can’t use this property to set the initial focus on a control of your choice.
The following procedure provides you with the ability to do exactly this
Sub SetControlFocus(ByVal ctrl As Control) Dim code As String = String.Format("", ctrl.ClientID) ctrl.Page.RegisterStartupScript("SetControlFocus", code)End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles _ MyBase.Load SetControlFocus( TextBox2 )End Sub