Tab Order Out Of Order

davearia

Centurion
Joined
Jan 4, 2005
Messages
184
I have a web page with 3 textboxes. I want them to tab from the top one to the middle and then to the bottom one. I have tried acheiving this two ways.

Firstly in the properties pane I set the tab index to 0 for the first, 1 for the second and 2 for the last textbox. When I run the code the focus starts on the first textbox then it jumps to the address box of internet explorer itself and then to the third textbox and finally to second textbox. Not quite what I had in mind.

Secondly I tried putting this code in the Page_Load:
Visual Basic:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TxtName.TabIndex = 0
        TxtEmail.TabIndex = 1
        txtMessage.TabIndex = 2
        Dim strScript As String
        strScript = "<script language=javascript> document.all('TxtName').focus() </script>"
        RegisterStartupScript("focus", strScript)
End Sub
The results were the same as the first approach. I don't understand why this is happening.

Has anyone got any ideas please?

Thanks, Dave. :D
 
I don't know about this Dave, but it seems like it was going backwards.... maybe try

[CS]
TxtName.TabIndex = 2
TxtEmail.TabIndex = 1
txtMessage.TabIndex = 0
[/CS]

Might possibly work? Sorry for my lack of knowledge in this area, just gave my observations...
 
Thanks for that coldfusion244.

Unfortunately it does exactly the same.

Up to now the only way to the tab order I want is to create the forms components in the order you wish them to tab in.

There must be a way of doing it other than that though?

Thanks again, Dave. :D
 
Back
Top