我在asp.net 中使用单选按钮列表控件。我试图在按钮单击事件上获取选定的值,但是,我得到Empty string
并且我想要它没有 javascript。
我怎样才能做到这一点?
<asp:RadioButtonList ID="RadioButtonList1" EnableViewState="true" runat="server"
Width="287px">
<asp:ListItem Value="Single" runat="server" Text="Single"></asp:ListItem>
<asp:ListItem Value="Jointly" runat="server" Text="Married Filing Jointly/Widower"></asp:ListItem>
<asp:ListItem Value="Separately" runat="server" Text="Married Filing Separately"></asp:ListItem>
<asp:ListItem Value="Household" runat="server" Text="Head Of Household "></asp:ListItem>
</asp:RadioButtonList>
C# 代码
protected void btnCalculate_Click(object sender, EventArgs e)
{
string selectedValue = RadioButtonList1.SelectedValue;
}