




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
PAGEPAGE1青島理工大學課程實驗報告三課程名稱Web開發技術及其應用班級實驗日期2012/10/姓名學號實驗成績實驗名稱.net2.0web控件的使用實驗目的及要求熟悉.netweb開發控件的使用以及事件的后臺響應函數實驗環境Windows7,visualstdio2010實驗內容使用CommandName、CommandArgument屬性來識別用戶按下了哪個按鈕。2.DropDownList控件的使用。3.FileUpload文件上載控件。算法描述及實驗步驟通過設置按鈕不同的屬性參數,區分同一個oncommand事件,并產生不同的行為,向DropDownList控件添加固定的3條選項,然后通過點擊按鈕“添加”為下拉控件動態增加一條可選項;點擊按鈕“刪除”刪除一條選中的下拉項;點擊按鈕“顯示”顯示選中的下拉項內容。實現讓用戶從客戶端選擇一個文件,然后放到web服務器的某個指定文件夾下。調試過程及實驗結果1.2.3.總結控件的使用并不復雜,主要是熟悉其中最常用的屬性,以及相應事件觸發函數的編寫,通過老師的輔導和自己的不懈努力總算成功編寫了出來。附錄源代碼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>無標題頁</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>}服務器端.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="濟?南?"></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>服務器端: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("煙¨?臺??§");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>服務器端: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('請?選?擇?要°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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 協同育人新模式的實踐路徑
- 物控員工作指導
- 算力中心建設與未來發展路徑
- 農村產業融合發展示范園初步設計方案
- 分布式光伏發電項目設計方案分析
- 2025年體育產業發展趨勢與市場前景深度解析
- 學校拔河比賽活動方案
- 興趣小組申請書
- 各學科聯動的教學活動安排計劃
- 學習品德教育的有效途徑計劃
- 股份代持協議合同6篇
- 2024-2025學年蘇教版七年級生物下冊知識點復習提綱
- DB32-T 5082-2025 建筑工程消防施工質量驗收標準
- 室速的觀察及護理
- 餐飲公司績效考核辦法
- 2025年03月春季河北邯鄲市叢臺區博碩人才引進50人筆試歷年參考題庫考點剖析附解題思路及答案詳解
- 2025年新高考歷史模擬試卷2(含答案解析)
- 急診一科一品一特色護理
- 物流行業招聘流程及人員配置
- 液化氣充裝站建站可行性研究報告
- 電力安全工作規程(完整版)
評論
0/150
提交評論