对于单选列表选项卡索引 [英] Tab index for RadioButton list

查看:111
本文介绍了对于单选列表选项卡索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何把一个标签指数为每个项目中的单选按钮列表?

How to put a tab index for each item in the radio button list?

推荐答案

通常情况下,这是不推荐的,因为它从标准的用户体验不符。因此,只有做到这一点,当你真的知道你在做什么。

Usually, this is not recommended, as it deviates from standard user experience. So, only do it, when you really know what you are doing.

<击>
在当你知道你在做什么的情况下,就用标准的HTML:

In the case when you know what you are doing, then just use standard HTML:

<input type="radio" name="radio" value="1" tabindex=2">Radio 1<br>
<input type="radio" name="radio" value="2" tabindex=1">Radio 2<br>

或在VisualStudio的:

Or in VisualStudio:

<asp:RadioButton ID="RadioButton1" TabIndex="2" runat="server" />
<asp:RadioButton ID="RadioButton2" TabIndex="1" runat="server" />

在重新阅读您的文章之后,这里是一些C#code,那你想要做什么,在VB code可以很容易地推断出:

After re-reading your posting, here is some C# code, that does what you want, the VB code can be deduced quite easily:

在前端侧:

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
    <asp:ListItem>test</asp:ListItem>
    <asp:ListItem>test2</asp:ListItem>
</asp:RadioButtonList>

在code背后:

protected void Page_Load(object sender, EventArgs e)
{
    int counter = 2;
    foreach (ListItem li in RadioButtonList1.Items)
    {   	
        li.Attributes.Add("tabindex", counter.ToString());
        counter -=1;
    }
}

这篇关于对于单选列表选项卡索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆