欢迎来到天天文库
浏览记录
ID:13906291
大小:42.50 KB
页数:4页
时间:2018-07-24
《.net 登录注册参考代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、登录usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Xml.Linq;usingSystem.Data.SqlClient;usingSystem.Data;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse
2、){}protectedvoidButton1_Click(objectsender,EventArgse){stringconnectionString=@"DataSource=.SQLEXPRESS;AttachDbFilename=C:UserslenovoDesktop王ª?晓t玲¢¨¢App_DataDatabase.mdf;IntegratedSecurity=True;UserInstance=True";//创ä¡ä建¡§获?取¨?数ºy据Y库a连¢?接¨®字Á?符¤?串ä?,ê?并¡é创ä¡ä建¡§数ºy据Y库a连¢?接¨®对?象¨
3、®stringsql="selectusername,passwordfromT1whereusername='"+TextBox1.Text+"'andpassword='"+TextBox2.Text+"'";SqlConnectionconn=newSqlConnection(connectionString);//实º¦Ì例¤y化¡¥连¢?接¨®对?象¨®SqlCommandcmd=newSqlCommand(sql,conn);//执¡ä行D命¨¹令¢?conn.Open();//打䨰开a数ºy据Y库aSqlDataReaderr=cmd.Execut
4、eReader();if(r.Read())//从䨮数ºy据Y库a读¨¢取¨?用®?户¡ì信?息¡é,判D断?是º?否¤?有®D记?录?{Response.Write("");//Response.Redirect("Text.aspx");}else{//if(username.Trim()!=TextBox1.Text
6、
7、password.Trim()!=TextBox2.Text)//判D断?用®?户¡ì名?密¨¹码?是º?否¤?一°?致?{Response.Write("
8、cript>alert('用®?户¡ì名?或¨°密¨¹码?错䨪误¨®!ê?!ê?!ê?');");//Label5.Text="用®?户¡ì名?或¨°密¨¹码?错䨪误¨®,请?重?新?输º?入¨?";//Response.Redirect("login.aspx");}}//else//{//Response.Write("");//}}protectedvoidButton2_Click(objectsender,EventArgse){Respon
9、se.Redirect("Register.aspx");//转Áa到Ì?注Á¡é册¨¢页°3}}注册usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Xml.Linq;usingSystem.Data.SqlClient;usingSystem.Data;usingSystem.Collections;usingSystem.Configu
10、ration;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls.WebParts;publicpartialclassDefault3:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){if(TextBox4.Text==String.Empty){Label4.Text="请?输º?入¨?内¨²容¨
此文档下载收益归作者所有