0

I have a CompositeControl that each contain a TextBox (TextBoxA) and three Buttons (ButtonA, ButtonB, and ButtonC). My page generates n of these CompositeControls dynamically depending on the state of the page.

I've set the TabIndex of TextBoxA to a positive value that increases by 1 for each Control during that Control's OnPreRender method:

TextBoxA.TabIndex = customControlPosition;
ButtonA.TabIndex = -1;
ButtonB.TabIndex = -1;
ButtonC.TabIndex = -1;

I've validated through debugging that customControlPosition is correctly assigning positive, incremental values (1, 2, 3, 4 etc.) to the TabIndex property.

The current behavior is that each press of the Tab Key moves the cursor to highlight each of the Buttons within the CompositeControl (which have a TabIndex of -1, and shouldn't be tabbed to), before continuing to put the cursor in the next CompositeControl's TextBox. What I want to do is have the Tab key move the focus directly from one TextBox to the TextBox in the next CompositeControl.

Is there something I'm missing that would allow me to do this?

Nick Orlando
  • 484
  • 1
  • 5
  • 17

2 Answers2

2

I found the issue.

The TextBox I was using is a custom class that was a wrapper of the asp:TextBox, and the custom class was not correctly assigning the TabIndex value to the asp:TextBox.

Nick Orlando
  • 484
  • 1
  • 5
  • 17
1

Try giving your buttons a TabIndex of 32767 (The maximum possible). The higher the number, the later the control is in the tab order.

I would imagine 32767 is a lot higher than the number of controls you will ever add to a page?

See this:

Tab Index

Oliver
  • 8,794
  • 2
  • 40
  • 60
  • I tried assigning the TabIndex of 32767 for each of the TextBoxes, and also also tried unique values of `(32700 + customControlPosition )` but have have the same behavior. The Tab Key moves to the Buttons within each control instead of the TextBox of the next Control. – Nick Orlando Mar 19 '13 at 13:53
  • The HTML output was not showing the tabindex value, which led me to [the answer](http://stackoverflow.com/a/15503840/745511). Thank you! – Nick Orlando Mar 19 '13 at 15:37