我需要知道RadioButton和RadioButtonList之间的区别,以及在决定使用哪种控件时需要遵循哪些指南?
我已经进行了研究,并决定在这里发布我的发现,以帮助说明我所发现的差异:
我学到了:
RadioButton
用于一次只显示一个单选按钮。可能需要设置group属性来将多个RadioButton控件关联成一个组。
RadioButtonList
用于显示一组RadioButton控件,自动提供group属性,将所有包含的RadioButton控件关联到单个组中。
观察
在UI中,只要在页面上放置至少2个或更多具有相同group属性值的RadioButton控件,两者在视觉上产生相同的结果。
UI示例代码如下:
asp: RadioButton
使用每种的指导方针是什么?
我已经进行了研究,并决定在这里发布我的发现,以帮助说明我所发现的差异:
我学到了:
RadioButton
用于一次只显示一个单选按钮。可能需要设置group属性来将多个RadioButton控件关联成一个组。
RadioButtonList
用于显示一组RadioButton控件,自动提供group属性,将所有包含的RadioButton控件关联到单个组中。
观察
在UI中,只要在页面上放置至少2个或更多具有相同group属性值的RadioButton控件,两者在视觉上产生相同的结果。
UI示例代码如下:
asp: RadioButton
<asp:RadioButton ID="b2b" text="B to B" checked="true" runat ="server" GroupName="businesstype" />
<asp:RadioButton ID="b2c" text="B to C" runat ="server" GroupName="businesstype" />
asp:RadioButtonList
<asp:RadioButtonList ID="businesstype" runat="server" >
<asp:ListItem Selected="True" Value="0">B to B</asp:ListItem>
<asp:ListItem Value="1">B to C</asp:ListItem>
</asp:RadioButtonList>
使用每种的指导方针是什么?