上帝救救我,各位大侠救救我!!

chenyirui121 2007-05-02 05:39:42
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时,它能从我这个用户控件登陆框里的用户名来判断用户是否登陆过.可是我怎么写错了啊.对了,所有代码我都是在用户控件里写的.各位老大帮我看看,谢谢!
...全文
130 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenyirui121 2007-05-02
  • 打赏
  • 举报
回复
怎么没人啊,各位老大,我实在没分了,要不然我把分都给你们了呵呵
chenyirui121 2007-05-02
  • 打赏
  • 举报
回复
没报错啊,不过这段代码else
{
Response.Write("<script>alert('用户名已经登陆');windows.location='newsMain.aspx';</script>");
Response.Redirect("newsMain.aspx");
}
好象没执行,我只是想当用户已经登陆了,就不可以再登陆了,然后用这个去判断!!
郁闷,是不是哪里错了,可以模仿我帮我写一个吗.然后用session来记录当前的用户名,设定过期时间:)
amandag 2007-05-02
  • 打赏
  • 举报
回复
报的什么错
chenyirui121 2007-05-02
  • 打赏
  • 举报
回复
怎么没人啊,各位帮帮忙呀

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧