I have a button that opens a panel in a popup window a开发者_如何转开发nd then performs a postback to retrieve data from the server and render some controls. Some of the controls are textboxes and some are dropdown lists and can be in any order. Everything works fine when tabbing through the textbox controls. But when tabbing from the first dropdown contorl found, the tab order 'gets lost' and it starts tabbing from the first control again. When I tab to the same dropdown list the second time 'round, it correctly tabs to the next control. Does anyone know what might be going on?
Example: TextBox1 (Tab -> focus set to 'TextBox2') TextBox2 (Tab -> focus set to 'DropDown1') DropDown1 (Tab -> focus goes back up to 'TextBox1' - wtf?) TextBox3
Update: The TabIndex attribute is set on all controls.
If you want to guarantee tab ordering you can simply set the TabIndex
properties on the controls. Here's a good article on the topic.
After a few days of playing around I figured out what was going on. The tab ordering wasn't being affected by controls being on a popup panel or by dynamically creating the controls. I had a tree in the background that was causing the problem, not sure exactly how it was gaining focus when tabbing from a dropdown list, but it was. I hid the tree using css (style="display: none")
and the tabbing problem went away.
Anyone else who is having weird tabbing issues in pop panels, check elements behind the popup to see if they are causing the problem.
精彩评论