我的users表里面是每人的信息,我在登陆的时候判断是普通会员还是管理员,下面是管理员专用登陆框,为什么判断不了呢?
public partial class Admin_gd_login : System.Web.UI.Page
{
User user = new User();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdminLogin_Click(object sender, EventArgs e)
{
if (this.txtAdminName.Text == "" || this.txtAdminPsw.Text == "")
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码不能为空!')</script>");
}
if (UserManager.GetUserByLoginId(this.txtAdminName.Text) != null)
{
user = UserManager.GetUserByLoginId(this.txtAdminName.Text); if (user.MemberGrade.ToString()=="管理员")
{
if (UserManager.ManagerLogin(this.txtAdminName.Text, this.txtAdminPsw.Text, out user))
{
Session["AdminName"] = this.txtAdminName.Text;
Response.Redirect("gd_admin.aspx");
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码错误!')</script>");
return;
}
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('对不起,您不是管理员!')</script>");
return;
}
}
}
protected void btnAdminCancel_Click(object sender, EventArgs e)
{
Response.Redirect("~/index.aspx");
}
}
public partial class Admin_gd_login : System.Web.UI.Page
{
User user = new User();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdminLogin_Click(object sender, EventArgs e)
{
if (this.txtAdminName.Text == "" || this.txtAdminPsw.Text == "")
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码不能为空!')</script>");
}
if (UserManager.GetUserByLoginId(this.txtAdminName.Text) != null)
{
user = UserManager.GetUserByLoginId(this.txtAdminName.Text); if (user.MemberGrade.ToString()=="管理员")
{
if (UserManager.ManagerLogin(this.txtAdminName.Text, this.txtAdminPsw.Text, out user))
{
Session["AdminName"] = this.txtAdminName.Text;
Response.Redirect("gd_admin.aspx");
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码错误!')</script>");
return;
}
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('对不起,您不是管理员!')</script>");
return;
}
}
}
protected void btnAdminCancel_Click(object sender, EventArgs e)
{
Response.Redirect("~/index.aspx");
}
}
解决方案 »
- 在父窗体上按一下按钮弹出子窗体在子窗体中有GridView,双击某一行,将这一行的值传到父窗体中并关闭子窗
- iis部署网站当前连接数超过5000网站就504错误,请大家不吝赐教
- 不晓得是oracle的错还是entityframework的错
- 如何实现给ASP.NET编写的软件加密?
- 关于Table控件和Table控件的使用
- repeater控件的特性
- 帮帮帮帮忙,,谢谢,,
- asp.net 如何实现如下图所示左侧导航?
- 请教,有人做过在线咨询那种网站吗?
- 分页存储过程返回字段值.想了一个通宵了.头晕先睡了.
- DropDownList数据绑定加了AutoPostBack="True"后默认下第一项选中了但是值为空
- php 代码 转asp.net 代码
user.MemberGrade.ToString()=="管理员"
看这句话的user.MemberGrade.ToString()==???
然后在找问题
是不是后面有空格
或者应该user.MemberGrade.ToString().Trim()