书签 分享 收藏 举报 版权申诉 / 14

类型《动态网页设计》 2.docx

  • 文档编号:7271901
  • 上传时间:2023-01-22
  • 格式:DOCX
  • 页数:14
  • 大小:214.25KB

usingSystem;

usingSystem.Data;

usingSystem.Configuration;

usingSystem.Linq;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.HtmlControls;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Xml.Linq;

usingSystem.Data.SqlClient;

usingSystem.Data.OleDb;

 

publicpartialclassdenglujiemian:

System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

}

protectedvoidButton1_Click(objectsender,EventArgse)

{

Stringusername=this.TextBox1.Text.ToString().Trim();

Stringps=this.TextBox2.Text.ToString().Trim();

Stringstr1="select*fromTableUserwhereUserID='"+username+"'";

StringstrConnect="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+Server.MapPath("~/TableUser.mdb");

OleDbConnectionaConnection=newOleDbConnection(strConnect);//建立指向数据库的连接

aConnection.Open();

//OleDbCommandaCommand=newOleDbCommand(str1,aConnection);

OleDbDataAdaptersda=newOleDbDataAdapter(str1,aConnection);

DataSetds=newDataSet();

sda.Fill(ds,"product");

DataTabledt=ds.Tables["product"];

if(dt.Rows.Count>0)

{

if(dt.Rows[0]["Password"].ToString()==ps)

{

this.Label1.Text="成功";

}

else

{

this.Label1.Text="失败";

}

 

}

else

{this.Label1.Text="失败";}

aConnection.Close();

}

protectedvoidButton2_Click(objectsender,EventArgse)

{

Response.Write("");

}

}

注册界面:

<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="zhuce.aspx.cs"Inherits="zhuce"%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

无标题页

.style1

{

width:

100%;

}

.style2

{

height:

61px;

}

.style3

{

width:

331px;

}

.style4

{

width:

123px;

}

.style5

{

width:

123px;

height:

20px;

}

.style6

{

height:

20px;

}

.style7

{

width:

331px;

height:

20px;

}

20px;margin-right:

auto;margin-left:

auto;width:

1046px;background-image:

url('7.jpg');height:

489px;">

用户注册

 

用户名:

TextBoxID="TextBox1"runat="server"Height="37px">

TextBox>

RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"

ControlToValidate="TextBox1"ErrorMessage="请输入用户名">*

RequiredFieldValidator>

 

 

密码:

TextBoxID="TextBox2"runat="server"TextMode="Password"Height="30px">

TextBox>

RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"

ControlToValidate="TextBox2"ErrorMessage="请输入密码">*

RequiredFieldValidator>

 

 

确认密码:

TextBoxID="TextBox3"runat="server"TextMode="Password"Height="32px">

TextBox>

CompareValidatorID="CompareValidator1"runat="server"

ControlToCompare="TextBox2"ControlToValidate="TextBox3"ErrorMessage="两次密码不一样">

CompareValidator>

 

 

 

 

 

 

 

ButtonID="Button1"runat="server"onclick="Button1_Click"Text="确定"

Height="37px"Width="59px"/>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

usingSystem;

usingSystem.Collections;

usingSystem.Configuration;

usingSystem.Data;

usingSystem.Linq;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.HtmlControls;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Xml.Linq;

usingSystem.Data.SqlClient;

usingSystem.Data.OleDb;

publicpartialclasszhuce:

System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

}

protectedvoidButton1_Click(objectsender,EventArgse)

{

Stringusername=TextBox1.Text.ToString();

Stringps=TextBox2.Text.ToString();

Stringstr="insertintoTableUser([UserID],[Password])values('"+username+"','"+ps+"')";

StringstrConnect="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+Server.MapPath("~/TableUser.mdb");

OleDbConnectionaConnection=newOleDbConnection(strConnect);//建立指向数据库的连接

aConnection.Open();

//Response.Write("");

OleDbCommandcom=newOleDbCommand(str,aConnection);

//com.Parameters.Add(newOleDbParameter("@UNAME",username));

//com.Parameters.Add(newOleDbParameter("@UPWD",ps));

com.ExecuteNonQuery();

aConnection.Close();

}

}

系统测试(进行运行截图)

4.结果分析及总结。

通过运行可以看出,我们利用数据库和验证控件,可以有效的管理数据。

也可以实现网页中的登录与注册,让我们的生活方便!

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
动态网页设计 动态网页设计 动态 网页 设计
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:《动态网页设计》 2.docx
链接地址:https://www.bdocx.com/doc/7271901.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开