开发者

How to Make Tab index work for Radio Buttons which are in same group?

I have a scenario like this

<asp:RadioButton ID="userActiveYesRadioButton" GroupName="activeGroup" Text="Yes"
       runat="server" TabIndex="4" />&nbsp;
<开发者_开发百科;asp:RadioButton ID="userActiveNoRadioButton" GroupName="activeGroup" Text="No"
       runat="server" TabIndex="5" />

Since these radio buttons are in same group , tab index is not working. Is is possible to make tabindex work in this scenario ? If I remove the group , they dont remain mutually exclusive.

Thanks in Advance


You can use an alternate, Remove GroupName attribute and use javascript to make radio buttons mutually exclusive.

For Example

function toggle(obj) {
    if (obj.value == "Radio1") {
        document.getElementById('ctl00_ContentPlaceHolder1_Radio2').checked = false;
    }
    else if (obj.value == "Radio2") {
        document.getElementById('ctl00_ContentPlaceHolder1_Radio1').checked = false;
    }
}

Call 'toggle(this)' on onClick event of radio buttons.

Note: 'ctl00_ContentPlaceHolder1_' is added to control id because of Content Place holder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜