| 发表于: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时,它能从我这个用户控件登陆框里的用户名来判断用户是否登陆过.可是我怎么写错了啊.对了,所有代码我都是在用户控件里写的.各位老大帮我看看,谢谢! |
|
|
|
|