I am working on an ASP.NET 2.0 web application. After making a change in a textbox and hitting Tab or Enter, the focus jumps to the web address bar instead of the next field.
I have tried:
1.SetFocus on the text change event
2.Saving last field in a hidden textbox and set focus to saved textbox name on Page Load if Post back
3.SetFocus on Pre_render

Still, focus jumps to browser address bar on tab or enter

Any clues?

Thanks in advance, any help is appreciated

Have you sent the tab index for the controls? If you aren't familar with it, in the properties for the control in the VS IDE you can see the tab index. This is simply a numerical control for setting the order the controls are reached via using tab. Control 1 leads to control 2 which leads to control 3 etc. Controls with a tab index of -1 are never focused when tab is hit (I believe, I haven't used a value of -1 in a while).
Simply enter the tab index for each control so it flows nicely. The focus moves to the address bar from the last control on the page that can accept focus.

Have you sent the tab index for the controls? If you aren't familar with it, in the properties for the control in the VS IDE you can see the tab index. This is simply a numerical control for setting the order the controls are reached via using tab. Control 1 leads to control 2 which leads to control 3 etc. Controls with a tab index of -1 are never focused when tab is hit (I believe, I haven't used a value of -1 in a while).
Simply enter the tab index for each control so it flows nicely. The focus moves to the address bar from the last control on the page that can accept focus.

Yes tab index is set throughout the entire page and tabs as expected unless you click a button or change text in a textbox, then it jumps to the address bar. I am thinking that it might be losing the tab index on post back.

Then other option is to set the Tab index dynamically, e.g. make the function in code behind file with all controls having tab index set on and call it on page post back when button is clicked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.