上帝救救我,各位大侠救救我!!
private void Page_Load(object sender, System.EventArgs e)
{ if(!this.IsPostBack)
{this.Panel2.Visible=false;
this.Panel1.Visible=true;
}// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.txtUser.TextChanged += new System.EventHandler(this.txtUser_TextChanged);
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void txtUser_TextChanged(object sender, System.EventArgs e)
{
}
private void btnLogin_Click(object sender, System.EventArgs e)
{
string loginUser=this.txtUser.Text;
string loginPwd=this.txtPwd.Text;
string key=this.txtUser.Text;
string user=Convert.ToString(Cache[key]);
if(user==null || user==string.Empty)
{
TimeSpan sessTimeout=new TimeSpan(0,0,System.Web.HttpContext.Current.Session.Timeout,120,0);
HttpContext.Current.Cache.Insert(key,key,null,DateTime.MaxValue,sessTimeout,System.Web.Caching.CacheItemPriority.NotRemovable,null);
Session["adminID"]=this.txtUser.Text;
if(operateClass.operate.selectUser(loginUser)&&operateClass.operate.selectPwd(loginPwd))
{
this.Panel2.Visible=true;
this.lblLoginUser.Text=loginUser;
// TimeSpan sessTimeout=new TimeSpan(0,0,System.Web.HttpContext.Current.Session.Timeout,120,0);
// HttpContext.Current.Cache.Insert(key,key,null,DateTime.MaxValue,sessTimeout,System.Web.Caching.CacheItemPriority.NotRemovable,null);
// Session["adminID"]=this.txtUser.Text;
// if(operateClass.operate.selectPwd(loginPwd))
// {
//// Response.Redirect("success.aspx");
//
// }
// else
// {
// Response.Redirect("loginFail.aspx");
// }
}
}
else
{
Response.Write("<script>alert('用户名已经登陆');windows.location='newsMain.aspx';</script>");
Response.Redirect("newsMain.aspx");
}
各位大狭,这个是在用户控件里写的,然后当我拖到newsMain.aspx时,它能从我这个用户控件登陆框里的用户名来判断用户是否登陆过.可是我怎么写错了啊.对了,所有代码我都是在用户控件里写的.各位老大帮我看看,谢谢!