As an alternative, I have been using the following technique to set the
focus to a specific field using javascript and the
RegisterStartupScript method. I first added the following procedure to
a class I called Utilities.
Public Class Utilities
Public Shared Sub SetFocus(ByVal ctrl As Control, ByVal myPage As
Page)
' Define the JavaScript function for the specified control.
Dim focusScript As String = "<script language='javascript'>" &
_
"document.getElementById('" + ctrl.ClientID & _
"').focus();</script>"
' Add the JavaScript code to the page.
If (Not myPage.IsStartupScriptRegistered("FocusScript")) Then
myPage.RegisterStartupScript("FocusScript", focusScript)
End If
End Sub
End Class
To call the setFocus script from any page just use the following line
in the pageload event where 'Me.txtLastName' is the Id of the field you
want to set the focus to.
'Set focus to desired field
Utilities.SetFocus(Me.txtLastName, Me)
Hope this helps.