获取角色名!!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class Login : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
///如果页面输入合法
if (Page.IsValid == true)
{
String userId = "";
string sClass = "";
///定义类并获取用户的登陆信息
Admin sAdmin = new Admin();
///对用户输入进行编码
string sUserName = Server.HtmlEncode(UserName.Text.Trim());
string sUserPwd = Server.HtmlEncode(Pwd.Text.Trim());
///获取用户信息
OleDbDataReader recu = sAdmin.LongeUsers2(sUserName,sAdmin.Encrypt(sUserPwd));
///判断用户是否合法
if (recu.Read())
{
userId = recu["UserId"].ToString();
sClass = recu["Class"].ToString();
}
recu.Close();
///验证用户合法性,并跳转到系统平台
if ((userId != null) && (userId != ""))
{
Session["UserId"] = userId;
Session["UserPwd"] = sUserPwd;
Session["UserName"] = sUserName;
Session["UserClass"] = sClass;//角色
//跳转到登录后的第一个页面
Response.Redirect("~/index.aspx");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", "<script>alert('用户名和密码错误,请重新再输入!');</script>");
}
}
}
}
怎么class 中的内容获不到!!
补充:.NET技术 , ASP.NET