RadioButtonList怎么获取不到选中项的值??
SelectedIndex ,SelectedValue ,SelectedItem 都获取不到选中的值,
直接贴代码:
<asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem Value="0">单数</asp:ListItem> <asp:ListItem Value="1">双数</asp:ListItem> </asp:RadioButtonList></td> <asp:LinkButton ID="lbtnDanTou" runat="server" onclick="lbtnDanTou_Click"><img src="images/toupiao.gif" /></asp:LinkButton>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void lbtnDanTou_Click(object sender, EventArgs e) { if (RadioButtonList1.SelectedValue == "0") { Response.Write... } else if (RadioButtonList1.SelectedValue == "1") { Response.Write... } else { Response.Write("<script>alert('未选中');</script>"); } } function GetRadioButtonValue(Name) { var rst; var input = document.getElementsByName(Name); for (var i = 0; i < input.length; i++) { if (input[i].checked) { rst = input[i].value; break; } } return rst; } alert(GetRadioButtonValue('RadioButtonList1'));