ASP.net中radiobutton的问题
我在UI页面设置的三个radiobutton:代码如下:<asp:RadioButtonID="RadAdmin"runat="server"GroupName="log...
我在UI页面设置的三个radiobutton:代码如下:
<asp:RadioButton ID="RadAdmin" runat="server" GroupName = "login" Checked="true"/>
<asp:Label ID="lblRadAdmin" runat="server" AssociatedControlID="RadAdmin" CssClass="inline">管理员</asp:Label>
<asp:RadioButton ID="RadTea" runat="server" GroupName = "login"/>
<asp:Label ID="lblRadTea" runat="server" AssociatedControlID="RadTea" CssClass="inline">教师</asp:Label>
<asp:RadioButton ID="RadStu" runat="server" GroupName = "login"/>
<asp:Label ID="lblRadStu" runat="server" AssociatedControlID="RadStu" CssClass="inline">学生</asp:Label>
在aspx.cs页面提示RadAdmin控件:
错误 1 当前上下文中不存在名称“RadAdmin”
if (RadAdmin.Checked) //提示错误
{
Model.Users.Users objUsers = new Model.Users.Users();
objUsers.UserNo = txtUserNo.Text.Replace("'", "''");
objUsers.UserNo = objUsers.UserNo.Trim();
那么请问,在aspx.cs文件中怎么用radiobutton控件获取其选中与否的值呢? 展开
<asp:RadioButton ID="RadAdmin" runat="server" GroupName = "login" Checked="true"/>
<asp:Label ID="lblRadAdmin" runat="server" AssociatedControlID="RadAdmin" CssClass="inline">管理员</asp:Label>
<asp:RadioButton ID="RadTea" runat="server" GroupName = "login"/>
<asp:Label ID="lblRadTea" runat="server" AssociatedControlID="RadTea" CssClass="inline">教师</asp:Label>
<asp:RadioButton ID="RadStu" runat="server" GroupName = "login"/>
<asp:Label ID="lblRadStu" runat="server" AssociatedControlID="RadStu" CssClass="inline">学生</asp:Label>
在aspx.cs页面提示RadAdmin控件:
错误 1 当前上下文中不存在名称“RadAdmin”
if (RadAdmin.Checked) //提示错误
{
Model.Users.Users objUsers = new Model.Users.Users();
objUsers.UserNo = txtUserNo.Text.Replace("'", "''");
objUsers.UserNo = objUsers.UserNo.Trim();
那么请问,在aspx.cs文件中怎么用radiobutton控件获取其选中与否的值呢? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询