Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top