|
-
Mar 7th, 2005, 07:20 AM
#1
Thread Starter
Lively Member
Set focus
When my page is shown, I want the first textfield to have the focus. I found somewhere a solution for this :
in the page_load I call a routine :
SetFocusControl(Page, Me.txtNr.ID.ToString)
... and the SetFocusControl-routine :
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
Now, all this works fine (field gets the focus and the whole contents is selected), but when I push TAB the focus goes to the Address-bar instead of the second textfield ??
Any idea why ? Are is there another 'better' solution to do this ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|