




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验名称基本控件实验实验目的熟练掌握各种控件的使用及事件的代码编写,能够掌握老师上课所讲的内容。实验设备MicrosoftVisualStudio2010实验过程(要求根据实现进行的过程,常用文字、图、表等描述,可另附页)1、创建Web窗体,使用Label控件显示文字“现在的时间是:以及具体时间,自行设置其文字颜色、字体、字号、背景色等属性;增加一个Button按钮,要求当按下该按钮后能改变Label控件上文字的字体、字号、颜色和边框样式。如:现在的时间是二2015-04-0?10:32:55改变显示样式|代码为:usingSystem;usingSystem.Collections.Gene
2、ric;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclass_Default:System.Web.UI.PageprotectedvoidPage_Load(objectsender,EventArgse)LabelLText=现在的时间是+DateTime.Now.ToString();protectedvoidButton1_Click(objectsender,EventArgse)Label1.Font.Name=宋体;Label1.F
3、ont.Size=12;LabelLBorderStyle=BorderStyle.Dotted;Labell.BorderColor=System.Drawing.Color.Blue;Labell.BackColor=System.Drawing.ColorTranslator.FromHtml(#cc00ff);Labell.ForeColor=System.Drawing.Color.Brown;Buttonl.Text=已改变样式;Buttonl.Enabled=false;运行结果为:IocaIhost:04&/WebSiteFVCISDJocalhost:2046/WebSi-t
4、e2/Default.aspx圈百度一下碱知道会我的首度峨博-随林海宝网-沟I我喜双茴胖现在的时间是2016/4/20星期三13:43:28改费显示样式|2、创建Web窗体,该窗体上有一个TextBox控件和一个Button控件,要求每当用户单击按钮时,文本框会显示数据反映单击的次数。如:代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefaul
5、t2:System.Web.UI.Pagestaticinti;protectedvoidPage_Load(objectsender,EventArgse)if(!IsPostBack)TextBoxl.Text=0;protectedvoidButton1_Click(objectsender,EventArgse)i=i+1;TextBox1.Text=i.ToString();运行结果为::国lxa山nstZCHb/WcbSit毋菖/0IocaIbost;04&/WebSrtcXCA|口I口匚Hh口st:2O46/Web5ite2/DgfduH2gspx圈百度一下畸知道“蒯哨页微博-随
6、时-朝海宝网-淘!我喜欢0你点了|5次按钮一定|3、创建Web窗体,其中包含三种不同类型的TextBox,分别为单行、密码和多行文本框,如果用户在密码框中输入的密码少于8位或大于15位,就弹出错误提示对话框,运行效果如下:用户名;ewew密码;eiijewe评谈:代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefault3:System.Web
7、.UI.PageprotectedvoidPage_Load(objectsender,EventArgse)protectedvoidTextBox2_TextChanged(objectsender,EventArgse)if(TextBox2.Text.Length15)Response.Write(scriptalert(密i码?必A?须?在28位?到t?15位?之?间?);protectedvoidButton1_Click(objectsender,EventArgse)protectedvoidTextBox3_TextChanged(objectsender,EventArgs
8、e)运行结果为:PhIocaIhost:2046/XQlocaIho&t:2046/X0locaIhostiZtMfi/1X,圈web窗体控件X1圈.CftDlocalhost:2046/WebSite2/Default3.aspxm百度一下r你就知道影我的首反微博-随时翅淘宝网-海:我喜欢茴噂晅阐第茸视频.D电用户名:而密码:F-dsds评论确认I4、4、利用image控件、button控件实现图片的更换,显示比例的调整。代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;using
9、System.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefault4:System.Web.UI.PageprotectedvoidPageLoad(objectsender,EventArgse)protectedvoidButton1_Click(objectsender,EventArgse)if(Imagel.ImageUrl=/image/1.jpg)Imagel.ImageUrl=/image/2.jpg”;elseImage1.ImageUrl=/image/1.jpg”;protectedvoidText
10、Box1_TextChanged(objectsender,EventArgse)protectedvoidButton2_Click(objectsender,EventArgse)doubleh=ImageLHeight.Value;doublew=Imagel.Width.Value;doublebl=Convert.ToDouble(TextBoxl.Text);Imagel.Height=newUnit(h*bl);Imagel.Width=newUnit(w*bl);;Ej-仔/M/eb咏七QlocalhQ5tr2O46/WebSfteXr-;,Cti.Dlacalhost:204
11、6/WebSite2/Default4.E国百度一F”同盅道w我的首页就技.,回澧金网-海!我喜输入囹片变换大彤.一确却匕IccaIhost*2046/V.ebSitx口localhost:2O46/VebSitexCWDlocalhost:2Q46/WebSite2/DefauIt4.aspx典百度一下,你就知道敲我的苴反赛博-随时朝淘宝网-海!我喜欢曲年喧临莘茸视频白电影换图输入图片变换大小:H确幻5、利用linkbutton控件的command事件实现图像的变换。代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Lin
12、q;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefault5:System.Web.UI.PageprotectedvoidPage_Load(objectsender,EventArgse)protectedvoidLinkButton_Command(objectsender,CommandEventArgse)Imagel.ImageUrl=/image/+e.CommandName.ToString()+”.jpg;protectedvoidLinkButto
13、n2_Click(objectsender,EventArgse)0-kxaIhost045/WebSitex、A於(Mf/WcbWk*jPllotE-CftDlocalhGst:2046/WebSi-te2/Default5.asp囤百度一F,你娥道会我的苣更啜逋磔时回海至网-靶I我喜欢1234jIocdIhost;04&/WebSitrxlocalhost;046/WebSitfK-TCrtDloclhost46/WebSite2/Default圈百度一F,你就幻道我的菖反常薄施甘翅海宛网-海!去12346、使用CheckBox和RadioButton控件进行男女生喜欢的手机品牌调查,单击
14、“确定”按钮后,将用户选择的信息显示出来,如:代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefault6:System.Web.UI.PageprotectedvoidButton1_Click(objectsender,EventArgse)if(RadioButtonl.Checked)Labell.Text=你?是。?男D生七,?;el
15、seLabell.Text=你?是。?女?生【七,?;Strings1,s2,s3;if(CheckBoxl.Checked=true)si=iphone;elsesi=;if(CheckBox2.Checked=true)s2=三y星?、elses2=;if(CheckBox3.Checked=true)s3=小?米iA;elses3=.so;Label2.Text=你?喜2欢?的t?手。?机七是?:eo+si+s2+s3;protectedvoidRadioButton1_CheckedChanged(objectsender,EventArgse)protectedvoidRadioBu
16、tton2_CheckedChanged(objectsender,EventArgse)protectedvoidCheckBox1_CheckedChanged(objectsender,EventArgse)protectedvoidCheckBox2_CheckedChanged(objectsender,EventArgse)protectedvoidCheckBox3_CheckedChanged(objectsender,EventArgse)运行结果为::,loca山ost;204b/Wsbit.ltxalhost;N(Mb/WGb5itE*jQlocalho&t;046/Wi
17、-嚏CISDlocalhost:2046/WebSite2/Default6.aspx囱百度一下,你就知道&我的首友哪博-遁甘髓)淘宝网-淘!我喜欢茴哗晅睥喳三;选择你的性别:男小女选择你喜欢的手机品牌:FiPhons甘三星“小米|确认|你是女生,你喜欢的手机是;iphcm巳三星小米7、使用CheckBoxList控件显示班长候选人,单击“投票”按钮,将选择的候选人的名字显示在Label控件中,运行效果如下:代码为:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.W
18、eb.UI;usingSystem.Web.UI.WebControls;publicpartialclassDefault7:System.Web.UI.PageprotectedvoidPage_Load(objectsender,EventArgse)protectedvoidCheckBoxList1_SelectedIndexChanged(objectsender,EventArgse)protectedvoidButton1_Click(objectsender,EventArgse)Strings=您f投”票iA给?了第:eo;for(inti=0;i9;i+)if(CheckBoxList1.Itemsi.Selected)s=s+CheckBoxList1.Itemsi.Text;L
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高支模支架监测安全防护措施
- 中学历史部编版九年级上册教学计划
- 钢结构建筑自然灾害引发事故原因及预防措施
- 五年级第二学期学生综合评价计划
- 小学英语学科教学效果评估计划
- 合同履行监管服务创新创业项目商业计划书
- 乐器演奏家音乐会版权代理创新创业项目商业计划书
- 国际贸易中介创新创业项目商业计划书
- 光电显示薄膜器件创新创业项目商业计划书
- 品牌国际化推广行动计划
- 叉车理论试题与参考答案
- 儿科学川崎病说课
- DB22T 2254-2015 退化羊草草地改良技术规程
- 《初中七年级《道德与法治》教材的新变化研究》
- 电力交易员培训课件
- 航天航空科普知识单选题100道及答案解析
- 化妆造型全套课件
- 电竞比赛规则与裁判执行标准
- 新版中国食物成分表
- GB/T 15843.2-2024网络安全技术实体鉴别第2部分:采用鉴别式加密的机制
- 煤矿整合关闭风险评估方案
评论
0/150
提交评论