tags:

views:

26

answers:

1

I've been trying to exclude an asp.net web control from the tabbing order. The control that i'm using is the RadioButtonList control. I've try setting the TabIndex to either 0 or -1. The problem that i'm running into is ... initially the control is skipped (which is good), but it seemed like the engine just shifted the control to the end of the tabbing order. Is this an expected behavior? or is there a work around for this?

After checking the HTML source, I have some interesting findings ...

<td><input id="rbSpiffType_0" type="radio" name="rbSpiffType" value="R" checked="checked" tabindex="-1" /><label for="rbSpiffType_0">Regular Spiff</label></td><td>

I think i might be tabbing into the label ... any ideas how to fix that in ASP.NET?

+1  A: 

Hey,

The issue may be the individual radio buttons don't have a tab index of -1, try looping through the RBL's Items collection, and do:

item.Attributes.Add("tabindex", "-1");

And see if that clears it up. It might actually be item.Attributes["tabindex"], can't remember the exact syntax at the moment.

Brian
I've tried your suggestion, but still no luck :(
aggietech
In the browser, right-click and view source, check the individual radio buttons to see if it is actually assigning tabindex proprety to the radio buttons.
Brian
@Brain, I updated the question. It seemed like the associated label might have something to do with the issue ...
aggietech
that could be very well the issue. If so, you'd have to set the tabindex for the label too. Here's the issue; no property exists to set directly in the label, which is a bummer (at least that I'm aware of). You'd have to add the tabindex via javascript. Do you have access to JQuery? You could do $("<%= CheckBoxList.ClientID %>").find("label").attr("tabindex", "-1"); otherwise, with pure JS, you could find the root tag name, and then use getElementsByTagName("label"), loop through each one, and then set the tabindex to -1.
Brian
@Brian, thanks man ... good suggestion i'll give that a try.
aggietech
I've tried the javascript approach where the label is the sibling of the input node, so far again no luck .. it'll always select the first item in the list at the end of the tabbing order :(
aggietech
Hey, consider your own custom control and dump the control altogether, or see if another control meets your need. Lastly, consider just rendering out radio buttons manually.
Brian
@Brian, yeah i thought of just using basic radio button controls .. or changing the requirements, thanks for all the help!
aggietech