web課程實(shí)驗(yàn)報(bào)告_第1頁
web課程實(shí)驗(yàn)報(bào)告_第2頁
web課程實(shí)驗(yàn)報(bào)告_第3頁
web課程實(shí)驗(yàn)報(bào)告_第4頁
web課程實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

PAGEPAGE1青島理工大學(xué)課程實(shí)驗(yàn)報(bào)告三課程名稱Web開發(fā)技術(shù)及其應(yīng)用班級(jí)實(shí)驗(yàn)日期2012/10/姓名學(xué)號(hào)實(shí)驗(yàn)成績(jī)實(shí)驗(yàn)名稱.net2.0web控件的使用實(shí)驗(yàn)?zāi)康募耙笫煜?netweb開發(fā)控件的使用以及事件的后臺(tái)響應(yīng)函數(shù)實(shí)驗(yàn)環(huán)境Windows7,visualstdio2010實(shí)驗(yàn)內(nèi)容使用CommandName、CommandArgument屬性來識(shí)別用戶按下了哪個(gè)按鈕。2.DropDownList控件的使用。3.FileUpload文件上載控件。算法描述及實(shí)驗(yàn)步驟通過設(shè)置按鈕不同的屬性參數(shù),區(qū)分同一個(gè)oncommand事件,并產(chǎn)生不同的行為,向DropDownList控件添加固定的3條選項(xiàng),然后通過點(diǎn)擊按鈕“添加”為下拉控件動(dòng)態(tài)增加一條可選項(xiàng);點(diǎn)擊按鈕“刪除”刪除一條選中的下拉項(xiàng);點(diǎn)擊按鈕“顯示”顯示選中的下拉項(xiàng)內(nèi)容。實(shí)現(xiàn)讓用戶從客戶端選擇一個(gè)文件,然后放到web服務(wù)器的某個(gè)指定文件夾下。調(diào)試過程及實(shí)驗(yàn)結(jié)果1.2.3.總結(jié)控件的使用并不復(fù)雜,主要是熟悉其中最常用的屬性,以及相應(yīng)事件觸發(fā)函數(shù)的編寫,通過老師的輔導(dǎo)和自己的不懈努力總算成功編寫了出來。附錄源代碼1.客戶端<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="ex_6_5.aspx.cs"Inherits="ex_6_5"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="/1999/xhtml"><headrunat="server"><title>無標(biāo)題頁</title></head><body><formid="form1"runat="server"><h3>ButtonCommandNameExample</h3>Clickononeofthecommandbuttons.<br><br><asp:ButtonID="Button1"Text="SortAscending"CommandName="Sort"CommandArgument="Ascending"OnCommand="CommandBtn_Click"runat="server"/> <asp:ButtonID="Button2"Text="SortDescending"CommandName="Sort"CommandArgument="Descending"OnCommand="CommandBtn_Click"runat="server"/><br><br><asp:ButtonID="Button3"Text="Submit"CommandName="Submit"OnCommand="CommandBtn_Click"runat="server"/> <asp:ButtonID="Button4"Text="UnknownCommandName"CommandName="UnknownName"CommandArgument="UnknownArgument"OnCommand="CommandBtn_Click"runat="server"/> <asp:ButtonID="Button5"Text="SubmitUnknownCommandArgument"CommandName="Submit"CommandArgument="UnknownArgument"OnCommand="CommandBtn_Click"runat="server"/><br><br><asp:LabelID="Message"runat="server"/></form></body></html>}服務(wù)器端.usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;publicpartialclassex:System.Web.UI.Page{protectedvoidCommandBtn_Click(Objectsender,CommandEventArgse){switch(e.CommandName){case"Sort"://Callthemethodtosortthelist.Message.Text="YouclickedtheSortAscendingbutton.";Sort_List((String)e.CommandArgument);break;case"Submit"://DisplayamessagefortheSubmitbuttonbeingclicked.Message.Text="YouclickedtheSubmitbutton";//Testwhetherthecommandargumentisanemptystring("").if((String)e.CommandArgument==""){//Endthemessage.Message.Text+=".";}else{//Displayanerrormessageforthecommandargument.Message.Text+=",howeverthecommandargumentisnotrecogized.";}break;default://Thecommandnameisnotrecognized.Displayanerrormessage.Message.Text="Commandnamenotrecogized.";break;}}protectedvoidSort_List(stringcommandArgument){switch(commandArgument){case"Ascending"://Insertcodetosortthelistinascendingorderhere.Message.Text="YouclickedtheSortAscendingbutton.";break;case"Descending"://Insertcodetosortthelistindescendingorderhere.Message.Text="YouclickedtheSortDescendingbutton.";break;default://Thecommandargumentisnotrecognized.Displayanerrormessage.Message.Text="Commandargumentnotrecogized.";break;}}protectedvoidButton5_Click(objectsender,EventArgse){}}源代碼2.客戶端:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><asp:DropDownListID="DropDownList1"runat="server"><asp:ListItemSelected="True"Value="臨¢¨′沂°¨o"></asp:ListItem><asp:ListItemValue="青¨¤島ìo"></asp:ListItem><asp:ListItemValue="濟(jì)?南?"></asp:ListItem></asp:DropDownList><asp:ButtonID="Button3"runat="server"Text="添?¨a加¨?"OnClick="a_click"/><asp:ButtonID="Button2"runat="server"Text="刪|?除y"OnClick="b_click"/><asp:ButtonID="Button1"runat="server"Text="顯?示o?"OnClick="c_click"/><div></div></form></body></html>服務(wù)器端:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoida_click(objectsender,EventArgse){ListItemli=newListItem("煙¨?臺(tái)??§");DropDownList1.Items.Add(li);}protectedvoidb_click(objectsender,EventArgse){DropDownList1.Items.Remove(DropDownList1.SelectedItem);}protectedvoidc_click(objectsender,EventArgse){Response.Write(DropDownList1.SelectedItem.Text);}}源代碼3.客戶端:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><div><asp:FileUploadID="FileUp"runat="server"style="height:19px"/><asp:ButtonID="Button1"runat="server"onclick="Button1_Click"Text="上|?傳??"/></div></form></body></html>服務(wù)器端:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;publicpartialclassDefault:System.Web.UI.Page{protectedvoidButton1_Click(objectsender,EventArgse){stringfullname=FileUp.PostedFile.FileName.ToString().Trim();if(fullname==""){this.Response.Write("<scriptlanguage='javascript'>alert('請(qǐng)?選?擇?要°a上|?載?的ì?圖a?片?文?件t!ê?')</script>");return;}stringfilename=this.FileUp.FileName.ToString();stringfiletype=fullname.Substring(fullname.LastIndexOf(".")+1);stringExt=filetype.ToLower();if(Ext=="jpg"||Ext=="bmp"||Ext=="gif"||Ext=="png"||Ext=="swf"){stringUploadedFile=Server.MapPath(".")+"\\"+filename;FileUp.PostedFile.SaveAs(UploadedFile);try{System.Drawing.ImagemylImage=System.Drawing.Image.FromFile(UploadedFile);intmyLength=FileUp.PostedFile.ContentLength;intmyWidth=mylImage.Width;intmyHeight=mylImage.Height;mylImage.Dispose();if(myLength>256000||myWidth>1900||myHeight>1300)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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ǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論