我正在使用ASP.NET创建一个web应用程序表单。以前,我使用复选框来接受一个用户输入,有3个选项:添加、编辑、删除。
使用一些服务器端和客户端代码在3种选择之间切换,并存储用户的最终答案。
然后我看到了“收音机按钮列表”。这是我的单子。
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Create a new enrollment.</asp:ListItem>
<asp:ListItem>Change my enrollment information.</asp:ListItem>
<asp:ListItem>Delete my account information.</asp:ListItem>
</asp:RadioButtonList>这太紧凑了!而不是在复选框选项之间切换。
但是,有人能告诉我如何在服务器端接受并存储客户端响应吗?
以前的复选框就像:-
if(CheckBox1.Checked){'do something';} 我不知道如何取得无线电按钮单上的个别项目。有人能帮我吗?
发布于 2013-08-08 23:07:41
使用SelectedIndex、SelectedItem和SelectedValue属性可能是最简单的。
switch(RadioButtonList1.SelectedValue)
{
case "foo":
// Do your stuff
break;
}
// or check it in some if's
if(RadioButtonList1.SelectedValue == "foo")
{
// Do your stuff
}https://stackoverflow.com/questions/18137653
复制相似问题