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

http://www.cnblogs.com/summers/archive/2013/07/31/3227234.html

.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 = 0;
if (friendHas.Checked == true)
model.Limits = 1;
if (publicHas.Checked == true)
model.Limits = 2;


RadioButtonList在.net中跟DropDownList用法相似,可以看成集合:
<asp:RadioButtonList ID="rbImg" Name="rbImg" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<asp:ListItem Value="1">是</asp:ListItem>
<asp:ListItem Value="0" Selected="True">否</asp:ListItem>
</asp:RadioButtonList>


.net后台处理方式:

this.radCid.SelectedValue = project.Cid;


radio
将name设置为相同的值
<input type="radio" name="sex" value="1" checked="checked"></input>男
<input type="radio" name="sex" value="0" ></input>女


.net后台处理方式:
通过Request.Form["sex"].ToString();获取

posted @   _海阔天空  阅读(1133)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
点击右上角即可分享
微信分享提示