<input type="radio" id="rbtnSing" runat="server"后台取值问题
<div>
<input type="radio" id="rbtnSing" runat="server" value="0" name="hobby" />Sing
<input type="radio" id="rbtnBasketball" runat="server" value="1" name="hobby" />Basketball
<input type="radio" id="rbtnpingpong" runat="server" value="2" name="hobby" />ping-pong
<input type="radio" id="rbtndance" runat="server" value="3" name="hobby" />dance
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<input id="Button2" type="button" value="button" onclick="GetRadioValue();" />
</div>
后台可以这样取
1.
if (rbtnSing.Checked)
{
}
else if(rbtnBasketball)
{
}
但这样很麻烦,我界面很多这样的不同分组radiobutton
2.在后台可以用
Request[name属性值], 但由于我是放在母版页中,还有用户控件中, name属性已经变了,变成像ctl00$ContentPlaceHolder1$hobby
我在后台.cs代码中怎么取到这个name属性值呢
[解决办法]
Request[rbtnBasketball.UniqueID]
你最好直接写html控件,去掉runat="server"
否则,name不同的radio,是不能单选的
[解决办法]
你最好
<input type="radio" value="0" name="hobby" />Sing
<input type="radio" value="1" name="hobby" />Basketball
<input type="radio" value="2" name="hobby" />ping-pong
<input type="radio" value="3" name="hobby" />dance
Request["hobby"]
[解决办法]