.net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法实例?

时间:2022-03-16 04:11:12
.net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法,区别?

RadioButton实例及说明:

<asp:RadioButton ID="publicHas" Checked="true" runat="server" CssClass="radioMiddle" Text="所有人可见" GroupName="mm"/>

<asp:RadioButton ID="privateHas" runat="server" CssClass="radioMiddle" Text="仅自己可见"  GroupName="mm" />

<asp:RadioButton ID="friendHas" runat="server" CssClass="radioMiddle" Text="仅好友可见"   GroupName="mm" />

.net后台处理方式:
if (privateHas.Checked == true)
model.Limits = ;
if (friendHas.Checked == true)
model.Limits = ;
if (publicHas.Checked == true)
model.Limits = ; RadioButtonList在.net中跟DropDownList用法相似,可以看成集合:
<asp:RadioButtonList ID="rbImg" Name="rbImg" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<asp:ListItem Value="">是</asp:ListItem>
<asp:ListItem Value="" Selected="True">否</asp:ListItem>
</asp:RadioButtonList> .net后台处理方式: this.radCid.SelectedValue = project.Cid; radio
将name设置为相同的值
<input type="radio" name="sex" value="" checked="checked"></input>男
<input type="radio" name="sex" value="" ></input>女 .net后台处理方式:
通过Request.Form["sex"].ToString();获取