做网站需要的带宽上行还是下行,网站开发样板,wordpress插件怎么使用,如何在网站上做跳转代码目录 一、测试要求
二、实现效果
三、实现代码 一、测试要求 二、实现效果 数据库中的内容#xff1a; 使用数据库中的账号登录#xff1a; 若不是数据库中的内容#xff1a;
三、实现代码
login.aspx文件#xff1a;
% Page LanguageC# AutoEventW…目录 一、测试要求
二、实现效果
三、实现代码 一、测试要求 二、实现效果 数据库中的内容 使用数据库中的账号登录 若不是数据库中的内容
三、实现代码
login.aspx文件
% Page LanguageC# AutoEventWireuptrue CodeBehindlogin.aspx.cs InheritsWebApplication2.login %!DOCTYPE htmlhtml xmlnshttp://www.w3.org/1999/xhtml
head runatserver
meta http-equivContent-Type contenttext/html; charsetutf-8/title/titlelink relstylesheet hrefStyleSheet1.css/style typetext/css.auto-style1 {width: 97%;height: 115px;}.auto-style2 {width: 137px;}.auto-style3 {height: 33px;}/style/head
bodyform idform1 runatserverdivbr /br /div idloginh1nbsp;/h1h1 classauto-style3登录/h1pnbsp;/ptable classauto-style1trtd classauto-style2用户名/tdtdasp:TextBox IDTextBox1 runatserver CssClasstxt/asp:TextBoxasp:RequiredFieldValidator IDRequiredFieldValidator1 runatserver ControlToValidateTextBox1 ErrorMessage× ForeColorRed/asp:RequiredFieldValidator/td/trtrtd classauto-style2密码/tdtdasp:TextBox IDTextBox2 runatserver CssClasstxt/asp:TextBoxasp:RequiredFieldValidator IDRequiredFieldValidator2 runatserver ControlToValidateTextBox2 ErrorMessage× ForeColorRed/asp:RequiredFieldValidator/td/tr/tablebr /br /br /br /asp:Button IDButton3 runatserver Height38px OnClickButton3_Click Text登录 Width110px /br /br /br /asp:LinkButton IDLinkButton1 runatserver OnClickLinkButton1_Click没有账号立即注册/asp:LinkButton/div/div/form
/body
/htmllogin.aspx.cs文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;namespace WebApplication2
{public partial class login : System.Web.UI.Page{string sqlconn ConfigurationManager.ConnectionStrings[userConnString].ToString();//建立connection链接对象这里最好设置成全局变量否则后面每次都得新建SqlConnection myconnection new SqlConnection();protected void Page_Load(object sender, EventArgs e){UnobtrusiveValidationMode UnobtrusiveValidationMode.None;myconnection.ConnectionString sqlconn;//Label1.Text myconnection.State.ToString();}//protected void Button1_Click(object sender, EventArgs e)//{// myconnection.Open();// Label1.Text myconnection.State.ToString();//}//protected void Button2_Click(object sender, EventArgs e)//{// myconnection.Close();// Label1.Text myconnection.State.ToString();//}protected void LinkButton1_Click(object sender, EventArgs e){Response.Redirect(zhuce.aspx);}protected void Button3_Click(object sender, EventArgs e){myconnection.Open();string name TextBox1.Text;string pwd TextBox2.Text;string sqlcmd select * from users where name name and pwd pwd ;SqlCommand mycommand new SqlCommand(sqlcmd, myconnection);SqlDataReader myreader mycommand.ExecuteReader();myreader.Read();if (myreader.HasRows){Response.Write(scriptalert(欢迎访问);/script);}else{Response.Write(scriptalert(账号或密码错误);/script);}myreader.Close();myconnection.Close();}}
}
stylesheet1.css文件
body {background-color:azure;
}
#login{width:600px;height:550px;border:1px solid black;background-color:white;margin:50px auto;text-align:center;
}
#login table{text-align:center;
}.txt{height:30px;width:270px;
}
register.aspx文件zhuce.aspx
% Page LanguageC# AutoEventWireuptrue CodeBehindzhuce.aspx.cs InheritsWebApplication2.zhuce %!DOCTYPE htmlhtml xmlnshttp://www.w3.org/1999/xhtml
head runatserver
meta http-equivContent-Type contenttext/html; charsetutf-8/title/titlelink hrefStyleSheet2.css relstylesheet/style typetext/css.auto-style1 {width: 95%;height: 164px;}.auto-style2 {height: 54px;}.auto-style3 {height: 54px;width: 235px;}.auto-style4 {width: 235px;}/style
/head
bodyform idform1 runatserverdiv idzhuceh1nbsp;/h1h1注册/h1table classauto-style1trtd classauto-style3用户名/tdtd classauto-style2asp:TextBox IDTextBox1 runatserver CssClasstxt1/asp:TextBoxasp:RequiredFieldValidator IDRequiredFieldValidator1 runatserver ControlToValidateTextBox1 ErrorMessage× ForeColorRed/asp:RequiredFieldValidator/td/trtrtd classauto-style4密码/tdtdasp:TextBox IDTextBox2 runatserver CssClasstxt1/asp:TextBoxasp:RequiredFieldValidator IDRequiredFieldValidator2 runatserver ControlToValidateTextBox2 ErrorMessage× ForeColor#FF3300/asp:RequiredFieldValidator/td/trtrtd classauto-style4确认密码/tdtdasp:TextBox IDTextBox3 runatserver CssClasstxt1/asp:TextBoxasp:CompareValidator IDCompareValidator1 runatserver ControlToCompareTextBox2 ControlToValidateTextBox3 ErrorMessage× ForeColorRed/asp:CompareValidator/td/tr/tablebr /br /asp:Button IDButton1 runatserver Height46px OnClickButton1_Click Text注册 Width133px /br /br /br /asp:LinkButton IDLinkButton1 runatserver OnClickLinkButton1_Click已有帐号立即登录/asp:LinkButtonbr /br /br /br /br /br //div/form
/body
/htmlregister.aspx.cs文件(zhuce.aspx.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;namespace WebApplication2
{public partial class zhuce : System.Web.UI.Page{string sqlconn ConfigurationManager.ConnectionStrings[userConnString].ToString();//建立connection链接对象这里最好设置成全局变量否则后面每次都得新建SqlConnection myconnection new SqlConnection();protected void Page_Load(object sender, EventArgs e){UnobtrusiveValidationMode UnobtrusiveValidationMode.None;myconnection.ConnectionString sqlconn;//Label1.Text myconnection.State.ToString();}protected void LinkButton1_Click(object sender, EventArgs e){Response.Redirect(login.aspx);}protected void Button1_Click(object sender, EventArgs e){myconnection.ConnectionString sqlconn;myconnection.Open();string name TextBox1.Text;string pwd TextBox3.Text;string sqlcmd insert into users(name,pwd) values ( name , pwd );SqlCommand mycommand new SqlCommand(sqlcmd, myconnection);mycommand.ExecuteNonQuery();Response.Write(scriptalert(添加成功);/script);myconnection.Close();}//protected void Button2_Click(object sender, EventArgs e)//{// myconnection.Open();// Label1.Text myconnection.State.ToString();//}//protected void Button3_Click(object sender, EventArgs e)//{// myconnection.Close();// Label1.Text myconnection.State.ToString();//}}
}
stylesheet2.css文件
body {background-color:azure;
}
#zhuce {width: 600px;height: 550px;border: 1px solid black;background-color: white;margin: 30px auto;text-align: center;
}
.txt1 {height: 30px;width: 270px;
}这次的测试我觉得我完成的也是可以的首先通过配置参数将网页与数据库进行了相连然后使用一个label和两个button一个是打开数据库一个是关闭数据库来验证配置参数的正确性验证完成之后按照题目的要求设置相应的格式。
后面有时间的话再完善一下。