取代RadioButtonList及RadioButton方法

此HTML标签<input id="Radio1" type="radio"/>可完全取代以上2个服务器控件。
RadioButtonList及RadioButton依赖于form窗体,产生很多垃圾代码,有时候只是用来显示此方法可取代。
aspx:
  <input type="radio" name="radio" id="test1" value="1" disabled="disabled" runat="server"/>
  <label for="test1">同意</label>
  <input type="radio" name="radio" id="test2" value="2" disabled="disabled" runat="server"/>
  <label for="test2">不同意</label>
cs:
if (strismk == "1") this.test1.Checked = true;
if (strismk == "2") this.test2.Checked = true;

如此可产生干净的页面代码. 

补充:如果项目很多的时候,name="radio"一定要改名,name="radio1",name="radio2",虽然页面代码里已经选上,可页面上看不到选上的迹象。

其他浏览器没有什么问题,发现Firefox中不能选中,一定要有name值才可以选中。

除了开放调试程序外,Firefox真的是一无是出,启动速度超慢,很多东西不兼容。 

转载于:https://www.cnblogs.com/cnaspnet/archive/2011/03/02/1969013.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值