用WEB控件實(shí)現(xiàn)注冊與登錄頁面_第1頁
用WEB控件實(shí)現(xiàn)注冊與登錄頁面_第2頁
用WEB控件實(shí)現(xiàn)注冊與登錄頁面_第3頁
用WEB控件實(shí)現(xiàn)注冊與登錄頁面_第4頁
用WEB控件實(shí)現(xiàn)注冊與登錄頁面_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、WEB系統(tǒng)開發(fā)實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)一實(shí)驗(yàn)題目:用WEB控件實(shí)現(xiàn)注冊與登錄頁面實(shí)驗(yàn)類型:驗(yàn)證性指導(dǎo)老師:潘鳳專業(yè)班級:計(jì)算機(jī)科學(xué)與技術(shù)系1103班姓 名:梁琪學(xué) 號(hào):(2011100307)2014年 03月 19日 1、 實(shí)驗(yàn)題目用web控件實(shí)現(xiàn)注冊與登錄頁面2、 實(shí)驗(yàn)?zāi)康暮鸵?. 利用所學(xué)知識(shí)進(jìn)行頁面開發(fā),充分運(yùn)用所能使用的服務(wù)器控件來實(shí)現(xiàn)需求。靈活掌握數(shù)據(jù)庫的連接與訪問。2. 要求頁面友好,交互性強(qiáng)。3. 上機(jī)前預(yù)習(xí)實(shí)驗(yàn),同學(xué)們相互間可以討論;上機(jī)過程中要求獨(dú)立完成;設(shè)計(jì)出具有各自風(fēng)格的頁面。3、 實(shí)驗(yàn)內(nèi)容1、 創(chuàng)建數(shù)據(jù)庫,創(chuàng)建數(shù)據(jù)表users用來存儲(chǔ)用戶信息,包含用戶名和密碼等字段。2、 用w

2、eb控件實(shí)現(xiàn)簡單的用戶注冊頁面。要運(yùn)用文本框、單選框、復(fù)選框、下拉列表、多行文本框、按鈕、文件上傳等控件實(shí)現(xiàn)注冊頁面,并實(shí)現(xiàn)簡單驗(yàn)證。點(diǎn)擊提交按鈕后講用戶填寫的信息寫入數(shù)據(jù)庫的數(shù)據(jù)表,并以文本的形式顯示出來。3、用web控件實(shí)現(xiàn)簡單的用戶登錄頁面運(yùn)用文本框、label、按鈕等控件實(shí)現(xiàn)簡單的用戶登錄頁面,登錄按鈕旁加上新用戶注冊按鈕,連接到用戶注冊頁面。用戶輸入用戶名和密碼后連接數(shù)據(jù)庫進(jìn)行驗(yàn)證,輸入正確則提示用戶歡迎登錄,并顯示歡迎圖片;否則提示用戶名或密碼錯(cuò)誤,顯示相應(yīng)錯(cuò)誤提示圖片。4、 實(shí)驗(yàn)代碼登錄界面代碼:Partial Class 登錄頁面 Response.Redirect("

3、;regist.aspx")End Sub Dim UserLoginName As String = TextBoxname.Text.Trim() Dim UserPwd As String = TextBoxpass.Text.Trim() Dim conn As New SqlConnection() Dim cmd As New SqlCommand() conn.ConnectionString = "server=localhost;database=student;uid=sa;pwd=" Dim sqlcomtext As String = &q

4、uot;select * from users where Uname='" & TextBoxname.Text & "' and Upass='" & TextBoxpass.Text & "'" conn.Open() Dim Sqlcom As SqlCommand = New SqlCommand(sqlcomtext, conn) If Sqlcom.ExecuteScalar() <> Nothing Then Session.Add("Unam

5、e", "UserLoginName") conn.Close() Response.Redirect("main.aspx") Else Response.Write("<script>alert('輸入的用戶名或密碼錯(cuò)誤')</script>") TextBoxname.Text = "" TextBoxpass.Text = "" TextBoxname.Focus() End Ifconn.Close() End SubEnd Class

6、2、登錄成功后的頁面代碼:Partial Class main Response.Redirect("login.aspx") End SubEnd Class3、注冊界面代碼:Partial Class 注冊頁面 MsgPanel.Visible = False ' 隱藏Panel控件 Dim conn As New SqlConnection '創(chuàng)建connection對象 Dim cmd As New SqlCommand Dim adpt As New SqlDataAdapter Dim ds As New DataSet conn.Connect

7、ionString = "server=localhost;database=student;uid=sa;pwd= " '設(shè)置connection對象的鏈接串" conn.Open() '打開連接 cmd.CommandText = "select * from users" '設(shè)置CMD對象的sql命令 cmd.Connection = conn '設(shè)置CMD對象的連接屬性 adpt.SelectCommand = cmd '設(shè)置查詢數(shù)據(jù)源的sql命令 adpt.Fill(ds, "user

8、s") conn.Close() End Sub Dim conn As New SqlConnection conn.ConnectionString = "server=localhost;database=student;uid=sa;pwd= " Dim cmd As New SqlCommand Dim adpt As New SqlDataAdapter adpt.SelectCommand = cmd cmd.CommandText = "select * from users" cmd.Connection = conn con

9、n.Open() adpt.InsertCommand = New SqlCommand adpt.InsertCommand.CommandText = "insert into users values (Uname,Upass,Uage)" adpt.InsertCommand.Connection = conn adpt.InsertCommand.Parameters.Add("Uname", SqlDbType.VarChar, 50, "Uname") adpt.InsertCommand.Parameters.Add(

10、"Upass", SqlDbType.VarChar, 50, "Upass") adpt.InsertCommand.Parameters.Add("Uage", SqlDbType.VarChar, 50, "Uage") Dim ds As New DataSet adpt.Fill(ds, "users") conn.Close() Dim usertab As DataTable = ds.Tables("users") usertab.Rows.Add(userR

11、ow) adpt.Update(ds, "users") End Sub Protected Sub ShowMsg(ByVal sender As Object, ByVal e As System.EventArgs) Dim i As Integer MsgIntrest.Text = "興趣:" For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(i).Selected Then MsgIntrest.Text = MsgIntrest.Text & CheckBoxList1.Items(i).Text End If Next MsgPanel.Visible = True ' 顯示Panel控件 End SubEnd Class5、 實(shí)驗(yàn)結(jié)果1、創(chuàng)建數(shù)據(jù)庫中的users表如下:2. 運(yùn)行登錄頁面,如下圖:3、 輸入用戶名與密碼,若正確,點(diǎn)擊登錄,則會(huì)轉(zhuǎn)到下圖:若用戶名和密碼與數(shù)據(jù)庫中的不對應(yīng),則會(huì)出現(xiàn)下圖:4、 回到登錄頁面,點(diǎn)擊注冊,則會(huì)出現(xiàn)下圖:5、 填入信息,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論