web课程实验报告_第1页
web课程实验报告_第2页
web课程实验报告_第3页
web课程实验报告_第4页
web课程实验报告_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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="临¢¨´沂°¨º"></asp:ListItem><asp:ListItemValue="青¨¤岛Ìo"></asp:ListItem><asp:ListItemValue="济?南?"></asp:ListItem></asp:DropDownList><asp:ButtonID="Button3"runat="server"Text="添¬¨ª加¨®"OnClick="a_click"/><asp:ButtonID="Button2"runat="server"Text="删¦?除y"OnClick="b_click"/><asp:ButtonID="Button1"runat="server"Text="显?示º?"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上¦?载?的Ì?图ª?片?文?件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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论