asp.net中的html控件和服务器控件及其值的获取
发布时间:2022-04-21 18:00:02浏览次数:
一、html表单控件
<input type="radio" name="nw" value="1" title="内网" checked="" runat="server">
<input type="radio" name="nw" value="2" title="外网" runat="server">
获取值:
Request.Form["nw"].ToString()
二、RadioButtonList服务器控件(单选框)
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1" Selected="True">男</asp:ListItem>
<asp:ListItem Value="2">女</asp:ListItem>
</asp:RadioButtonList>
获取值:
//获取Text的值
RadioButtonList1.SelectedItem.Text
//获取Value的值
RadioButtonList1.SelectedItem.Value