




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、基于.net開發(fā)技術(shù)實驗指導(dǎo)書(適用于計算機(jī)科學(xué)與技術(shù)、網(wǎng)絡(luò)工程專業(yè)、軟件工程專業(yè))計算機(jī)科學(xué)與工程學(xué)院軟件教研室2011-10實驗1 html網(wǎng)頁制作一、目的與要求1. 掌握html常用網(wǎng)頁標(biāo)記的使用。2. 掌握表格的建立方法。3. 學(xué)握表單的建立方法。二、實驗環(huán)境任何一個文本編輯器、ie或者其它網(wǎng)頁瀏覽器三、內(nèi)容和步驟【實驗題1在網(wǎng)頁上創(chuàng)建一個課表。步驟如下。1. 打開記事本,輸入如下代碼,并以testl_l.html為文件名保存該文件:<html><headxtitle >表格標(biāo)記應(yīng)用 </titlex/head><body><tab
2、le border id二”table 1“><caption>課表 v /caption><tr><th>節(jié)次 <7thxt h> 星期一 <7thxth> 星期二 v/th><th>星期三</thxth >星期四</thxth >星期五</th></tr><tr>vtd>l、2</td>vtd>專業(yè)英語</td>vtd>操作系統(tǒng)<ftd>vtd>網(wǎng)絡(luò)基礎(chǔ)</td>vtd&
3、gt;專業(yè)英語</td>vtd>數(shù)據(jù)庫</td></tr><tr>vtd>3、4<ftd><td>java</td>vtd>數(shù)據(jù)庫</td><td > 實驗 v /td><td>java</td>vtd>操作系統(tǒng)<ftd></tr><tr><td>5 > 6</td><td >網(wǎng)絡(luò)基礎(chǔ)</td><td > 實驗 v /td>&l
4、t;td > 實驗 <ftd><td > 實驗 <atd>vtd>操作系統(tǒng)</td></tr></table></body></html>2. 通過瀏覽器打開該文件,得到該程序的執(zhí)行結(jié)果,如圖11所示。r課表苗次星期一星期二星期三星期四星期五|1、2|專業(yè)英語臊作系統(tǒng)|網(wǎng)絡(luò)基礎(chǔ)|專業(yè)英語數(shù)據(jù)庫|3、4java數(shù)據(jù)庫實驗java操作系統(tǒng)|5、6網(wǎng)絡(luò)基礎(chǔ)實驗實驗實驗操作系統(tǒng)圖1-1 “課表”網(wǎng)貝運(yùn)行結(jié)果【實驗題2】創(chuàng)建一個新用戶注冊的表單。步驟如下。1. 打開記事本或其它文本編輯工具,添加如
5、下代碼,并以testl-2.html為文件名保存該文件; <htmlxhead><title > 新用戶注冊 </titlex/head><body bgcolor=h#0099ffh><form action="userreg.aspx" method=upost"><h3>新用戶注冊v/h3>姓 名:vinputtype二“text” id二”姓名“name姓名”xbr>性 別:<select size=,f, name=husersexh tabindex二”5” id
6、=“selectl”> <option selected value男、男</option><option value女”女</option></select><br>地 址:vinput type二”text” id二”地址“ name-'地址”xbr> 郵政編碼:<input type=ntext,r id=,r郵政編碼” name=”郵政編碼”xbr> 電 話:vinput (ype=”(exfid=” 電話“ name-'電話hxbr> 電子郵件:<input type二“t
7、ext” id二”電子郵件” name二”電子郵件”xbr> 個人愛好:vbr><input typc=nchcckboxn namc=hchcckboxhvalue 二"checkbox”ld=ncheckbox 1 ”> 體育<input type=mcheckboxu name=ucheckboxn value=ncheckboxn id=mcheckbox2m>音樂vbr><input type= checkboxname= cheekboxvalue= checkboxid="checkbox3">
8、上網(wǎng) vinput type=,checkboxm name二"checkbox" value="checkboxm id=ncheckbox4m> 旅游 <br><br><pxinput type=,submith id=,btnsubn name=mbtnsubh value=n注冊”<input typc="rcscth valuc=m重寫” namc=nb2h tabindcx=,'9,' id=nrcsctl h></p></form><p align
9、=ncenterh><a href="index.htmn>返回</a>v/p></body> </html>2. 通過瀏覽器打開該文件,得到該程序的運(yùn)行結(jié)果,如圖1-2所示。圖1-2 “浙用戶注冊”運(yùn)行結(jié)果名別址姓性地四. 思考與練習(xí)1. 網(wǎng)頁的基本語法格式是什么?包含了哪些內(nèi)容?2. 試使用html制作一個人主頁,將接受教育的情況用表格在網(wǎng)頁上列出來。實驗2 vc#.net中類的設(shè)計一、目的與要求1. 掌握類的定義和使用。2. 掌握類的定義和對彖的聲明。3. 掌握具有不同訪問屬性的成員的訪問方式。4. 觀察構(gòu)造函數(shù)和析構(gòu)
10、函數(shù)的執(zhí)行過程。5. 定義一個類作為類的數(shù)據(jù)成員。二、實驗環(huán)境1. 計算機(jī)一臺;2. microsoft visual studio .net 2005 工具軟件;三、內(nèi)容和步驟【實驗題1】完成下列的要求:1. 自定義一個類,名稱為myclasso2. 定義數(shù)據(jù)成員定義,定義一個常量成員,定義一個變量成員,定義一個靜態(tài)變量成員。3. 定義類的方法成員,定義一個類的方法,定義一個成員方法。4. 實現(xiàn)構(gòu)造函數(shù),和析構(gòu)函數(shù)。5. 在主函數(shù)中対以上成員進(jìn)行正確的訪問。步驟如下1定義一個類名字為myclasso實現(xiàn)要求的成員定義,可以參考如下代碼,適當(dāng)添加相應(yīng)的 其他成員定義:using system;
11、class myciasspublic myclasso console.wriieline(nlnstance constructor11);public myciass(int value) myfield = value:console,writeline(hinstance constructorm);)myclass() console. writclinc(hdcstnjctorh);)public const int myconst = 12;public int myfield = 34;public void mymethod()console. writclinc(nmyc
12、iass.mymcthodm);)public int myproperty get return myfield;)set myfield = value;)public int thisint index gel return 0:)set console.writelinechislfo) = 1", index, value);)public event evcnthandlcr myevcnt;public static myclass operator+(myclass a, myclass b) return new myclass(a.myfield + b.myfi
13、eld);)internal class mynestedciass)2創(chuàng)建-個包含主函數(shù)的類來訪問myclass類,可以參考如f代碼:class teststatic void main() / instance constructor usagemyclass a = new myclass();myclass b = new myclass(123);/ constant usageconsole.writeline(nmyconst = ()'; myclass.myconst);/ field usagea.myfield+;console.writeline("a
14、.myfield = 0)", a.myfield);/ method usagea.mymethod();/ property usagea.myproperty+;console,writeline(ma.myproperty = 0)* a.myproperty);/ indexer usagea3 = al = a2;console.writeline(”a3 = 0", a3);/ event usagea.myevent += new eventhandler(myhandler);/ overloaded operator usagemyclass c = a
15、 + b;)static void myhandler(object sender, eventargs e) console. writeline(ntest.myhandlerh);)internal class mynestedclass()3對以上代碼進(jìn)行添加修改,然后進(jìn)行調(diào)試,使其能夠正確運(yùn)行,得到相應(yīng)的正確結(jié)果。!1!思考與練習(xí)1 類中不同訪問屬性的成員訪問方式是什么?2. 怎樣定義一個類?如何聲明一個對彖?實驗3 .net的數(shù)據(jù)庫程序設(shè)計一、目的與要求1. 熟悉基本的數(shù)據(jù)庫應(yīng)用程序設(shè)計的流程;2. 熟悉如何利用ado.net來處理數(shù)據(jù)庫類型的應(yīng)用;二、實驗環(huán)境visual stu
16、dio 2005 或者 visual studio 2008sql server 2005 或者 sql server 2000三、內(nèi)容和步驟【實驗題】實現(xiàn)用戶登錄或新用戶注冊的功能步驟如下。1. 在sql server 2005中創(chuàng)建一個use數(shù)據(jù)庫,并在這個數(shù)據(jù)庫中建立一個表member, member 表包含二個字段,分別是 name(pk,nvarchar(50), not null);password(nvarchar(20), not null) ;emil(nvarchar(50), null)。2. 新建一個web應(yīng)用項冃。3. 創(chuàng)建用戶登錄或新用戶注冊的程序主頁而窗體tets
17、t.l.aspx,頁面界而如圖1所示。頁 而上有三個labek 二個textbox.三個button共八個 web控件。abel33. 進(jìn)入程序編輯窗1丨,在三個按鈕對應(yīng)的事件中輸入以下程序代碼:private void button l_click(objcct sender, system. event args c)實現(xiàn)用戶登錄功能string user=this.textboxuser.text.trim();string pwd=this.textboxpwd.text.trim();string strconn = ”sevei二】ocalhostsqlexp2ss;dakibas
18、e=use;uid二sa;pwd="sqlconncction con=ncw system.data.sqlclicnt.sqlconncction();sqlcommand mycomtnand = new sqlcomniand(mselect * from member where user=h,+user+,h and password=h,+pwd+mm, con);con.open();int count= mycommand.executescalar();if(count=l)this.labcl3.tcxt=”恭喜,您已經(jīng)成功登錄! ”;elsethis.labe
19、l3.text=m<script language='jscript'> alertc登錄信息有誤!');</script>,'con.colse();private void button2_click(object sender, system.eventargs e)實現(xiàn)重置功能this.textboxuser.text=,m,;this.textboxpvd.text=h")private void button3_click(object sender, system.eventargs e)實現(xiàn)用戶注冊功能respo
20、nse.redirect(test_2.aspxh);)4. 如果是新用戶,單擊注冊,進(jìn)入test_2.aspx頁而,頁而界而如圖2所示。5. 進(jìn)入程序編輯窗口,対應(yīng)按鈕的事件中輸入以下程序代碼:protected void button 1 _click(object sender, system.eventargs e)實現(xiàn)用戶注冊的確認(rèn)功能if(this.textboxuser.text=,h)this.labclmcssagc.tcxt=m<script 1 anguagc=* j scri pt*> alcrt( 您必須輸入用戶名!,);</script>h;
21、)else string user=this.textboxuser.text;string strconn = nserver=iocalhostsqlexpress;database=use;uid=sa;pwd=n;sqlconncction con=ncw system.data.sqlclicntsqlconncction();sqlconmiand mycommand = new sqlcommand(mselect * from member where user=h,+user+mm con);con.open();int count二 myconimand.exccutcsc
22、alaro;if(count!=0)this.labelmessage.text="<script language='jscript'> alertc您輸入的用八名已存在,請重新設(shè)置!'):</script>" else if(this.texlboxpwd.text!=lhis.textboxrpwd.texl)this.labelmessage.text=m<script language=,jscript,> alertc 二次輸入的密碼不致,請確認(rèn)后重試!');</script>&qu
23、ot; else(this.labelmessage.text=',h;try設(shè)置命令參數(shù)(參數(shù)名、類型、長度、所示列名)【hisrnycommandparame【ersaddcusef;syslemdaasqldbtypencha,iouser”);this. mycommand. parameters. add(”email”, system. data. sqldbtype.nchar,20, "email”);this.mycommand.parameters. add(hpwdh,systcm.data.sqldbtypc.nchar,20,"密碼”);t
24、his. mycommand. parameters. add(” email 蔦 system. data.sqldbtype.nchar,20,"email");this.mycommand.parameterslemairj.valuehis.textboxemail.text; lhis.mycommandparameiersrpw(tvaluenhistex(boxpwdtexl;this.mycommand.commandtext=hinsert into memberlnfo(user,passwor,email) values(user, pwd, emai
25、l)"無返回值的數(shù)據(jù)査詢進(jìn)行記錄更新this.myconnection.openo;this.mycommand.executenonquey();this.myconnection.close();this.labelmessage.text="您已經(jīng)注冊成功 了!"catch(exception exc)this.labelmessage.texl=exc.message;this.myconnection,close();1)protected void button2_click(object sender, system.eventargs e)/實現(xiàn)注
26、冊的重置功能this.tcxtboxuscr.tcxt=mh;this.textboxpvd.text=hu;this.textboxrpwd.text=nh;this.textboxemail.text=,m,;this.labelmessage.text="in 填歸注冊內(nèi)容!";)6. 編譯、運(yùn)行程序,觀察結(jié)果。四、思考與練習(xí)1. 如何實現(xiàn)與數(shù)據(jù)庫的連接?實驗4 .net的xml程序設(shè)計一、目的與要求1. 熟悉基本的xml文檔應(yīng)用程序設(shè)計的流程;2. 熟悉如何利用dataset對彖和xml控件來處理xml文檔的應(yīng)用;二、實驗環(huán)境visual studio 2005 或者 visual studio 2008sql server 2005 或者 sql server 2000三、內(nèi)容和步驟【實驗題】實現(xiàn)xml文檔讀取和數(shù)據(jù)表綸成的功能步驟如下。1. 新建一個web應(yīng)用項目。2. 使用dataset讀取xml文件,并將dataset的內(nèi)容寫入數(shù)據(jù)庫。(給定xml文檔)3. 使用xml控件讀取xml文件并在頁而中顯示。4. 使用datagrid控件修改xml文件的內(nèi)容?;蚴褂胐ataset修改xml文件的內(nèi)容。5. 編譯、運(yùn)行程序,觀察結(jié)果。四、思考與練習(xí)1. 如何實現(xiàn)xml與數(shù)據(jù)庫的連接、修改和顯示內(nèi)容
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 客服員工合同協(xié)議書
- 演員開機(jī)協(xié)議書
- 2025年基于云計算的在線醫(yī)療服務(wù)平臺可行性研究及評估報告
- 營銷咨詢合同協(xié)議書
- 運(yùn)輸砂石料付款合同協(xié)議
- 紡織品檢驗員證書考試戰(zhàn)術(shù)與策略分析 試題及答案
- 未婚領(lǐng)養(yǎng)協(xié)議書
- 車庫承包支模合同協(xié)議
- 民宿入伙協(xié)議書
- 紡織工程師考試題目的構(gòu)成試題及答案
- 思想道德與法治教案第一章:領(lǐng)悟人生真諦把握人生方向
- 61850報文解析-深瑞版-131016
- 0-6歲兒童隨訪表
- 江西新定額2017土建定額說明及解釋
- 國家電網(wǎng)有限公司十八項電網(wǎng)重大反事故措施(修訂版)-2018版(word文檔良心出品)
- 語文四年級下冊《失落的一角》繪本閱讀 課件(共61張PPT)
- 附件一∶ 教育部專家實地評估案頭必備材料
- 余甘果的栽培與加工工藝
- 中考英語雙向細(xì)目表
- (完整版)全usedtodo,beusedtodoing,beusedtodo辨析練習(xí)(帶答案)
- 2002年湖北高考理科數(shù)學(xué)真題及答案
評論
0/150
提交評論