您的位置:程序门 -> .net技术 -> asp.net



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


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


上帝救救我,各位大侠救救我!!
发表于:2007-05-02 17: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时,它能从我这个用户控件登陆框里的用户名来判断用户是否登陆过.可是我怎么写错了啊.对了,所有代码我都是在用户控件里写的.各位老大帮我看看,谢谢!
发表于:2007-05-02 19:30:451楼 得分:0
怎么没人啊,各位帮帮忙呀
发表于:2007-05-02 19:34:192楼 得分:0
报的什么错
发表于:2007-05-02 19:40:213楼 得分:0
没报错啊,不过这段代码else
{
response.write( " <script> alert( '用户名已经登陆 ');windows.location= 'newsmain.aspx '; </script> ");
response.redirect( "newsmain.aspx ");
}
好象没执行,我只是想当用户已经登陆了,就不可以再登陆了,然后用这个去判断!!
郁闷,是不是哪里错了,可以模仿我帮我写一个吗.然后用session来记录当前的用户名,设定过期时间:)
发表于:2007-05-02 21:32:574楼 得分:0
怎么没人啊,各位老大,我实在没分了,要不然我把分都给你们了呵呵


快速检索

最新资讯
热门点击