实验4 服务器控件的使用.docx

实验4 服务器控件的使用.docx

ID:61040412

大小:82.92 KB

页数:3页

时间:2021-01-20

实验4 服务器控件的使用.docx_第1页
实验4 服务器控件的使用.docx_第2页
实验4 服务器控件的使用.docx_第3页
资源描述:

《实验4 服务器控件的使用.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、实验4服务器控件的使用目的与要求(1)掌握常用的Web服务器控件的使用方法。(2)熟悉各控件的常用属性和方法。(3)掌握验证控件的使用方法。内容和步骤【实验题4.1】使用Web服务器控件Label、TextBox和Button,设计如图p4.1所示的页面。使用C#语言,实现基本的加减乘除运算功能,并将计算结果输出。图4.1实验题4.1界面步骤如下:(1)启动VisualStudio2010,单击“创建:项目…”链接,即弹出“新建项目”对话窗口,左侧“项目类型”列表框选中选择“VisualC#→Web”;在“模板”列表框中

2、选择“ASP.NETWeb应用程序”。定义项目名称,并设置项目存储位置。(2)在Design视图,从Toolbox窗口选择若干控件,设置各控件属性及布局。(3)编写逻辑代码:protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){LabelNum1.Text=LabelNum2.Text="0";}}protectedvoidgetInputValue(objectsender,EventArgse){TBResult.Text+=((Butto

3、n)sender).Text;}protectedvoidDispose(objectsender,EventArgse){switch(((Button)sender).Text){case"+":LabelNum1.Text=TBResult.Text;LabelOperator.Text="+";TBResult.Text+=LabelOperator.Text;break;case"-":LabelNum1.Text=TBResult.Text;LabelOperator.Text="-";TBResult.Te

4、xt+=LabelOperator.Text;break;case"*":LabelNum1.Text=TBResult.Text;LabelOperator.Text="*";TBResult.Text+=LabelOperator.Text;break;case"/":LabelNum1.Text=TBResult.Text;LabelOperator.Text="/";TBResult.Text+=LabelOperator.Text;break;case"C":TBResult.Text="";LabelNum1

5、.Text=LabelNum2.Text="0";LabelOperator.Text="";break;}}protectedvoidcalculate(objectsender,EventArgse){switch(LabelOperator.Text){case"+":LabelNum2.Text=TBResult.Text.Substring(LabelNum1.Text.Length+1);TBResult.Text+="="+(Int32.Parse(LabelNum1.Text)+Int32.Parse(L

6、abelNum2.Text)).ToString();break;case"-":LabelNum2.Text=TBResult.Text.Substring(LabelNum1.Text.Length+1);TBResult.Text+="="+(Int32.Parse(LabelNum1.Text)–Int32.Parse(LabelNum2.Text)).ToString();break;case"*":LabelNum2.Text=TBResult.Text.Substring(LabelNum1.Text.Le

7、ngth+1);TBResult.Text+="="+(Int32.Parse(LabelNum1.Text)*Int32.Parse(LabelNum2.Text)).ToString();break;case"/":LabelNum2.Text=TBResult.Text.Substring(LabelNum1.Text.Length+1);TBResult.Text+="="+(double.Parse(LabelNum1.Text)/double.Parse(LabelNum2.Text)).ToString()

8、;break;}}}}(3)编译运行,结果如p4.2所示。图p4.2实验题4.1的运行结果【实验题4.2】使用Web服务器控件TextBox、Button、CheckBox、RadioButton、DropDownList、Image、Calendar、FileUpload等以及各种验证控件,设计如图p4.3所示的页

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。