实验二ASPNET常用服务器控件淮海工学院.docx
《实验二ASPNET常用服务器控件淮海工学院.docx》由会员分享,可在线阅读,更多相关《实验二ASPNET常用服务器控件淮海工学院.docx(35页珍藏版)》请在冰豆网上搜索。
![实验二ASPNET常用服务器控件淮海工学院.docx](https://file1.bdocx.com/fileroot1/2023-1/8/c1d36991-5056-4df1-944a-2b921d08c678/c1d36991-5056-4df1-944a-2b921d08c6781.gif)
实验二ASPNET常用服务器控件淮海工学院
淮海工学院计算机科学系
实验报告书
课程名:
《计算机新技术
(二)》
题目:
ASP.NET常用服务器控件
班级:
*******
学号:
201*******
姓名:
***
一.实验目的
通过实验,掌握常用服务器控件的属性、事件、方法的定义和使用.主要包括:
Label、TextBox、各类Button、RadioButton、RadioButtonList、CheckBox、CheckBoxList、DropDownList、ListBox和数据验证控件、导航控件等。
二.实验内容和要求
实验内容:
首先新建名字为WebControl的网站,然后在网站中按以下要求依次完成设计:
(1)在Default.aspx页面中,添加1个TextBox控件、2个Button控件、一个ListBox控件。
2个Button控件的Text属性分别改为"增加"和"删除"。
当单击[增加]按钮时,将TextBox文本框中的输入值添加到ListBox中,但单击[删除]按钮时,删除ListBox中当前选定的项。
(2)添加一个网页,要求将Label控件、LinkButton控件、HyperLink控件放在Panel控件中,当单击一组Button按钮时改变Panel控件的背景色,单击另一组Button控件时改变Panel控件中文字的大小。
单击LinkButton和HyperLink控件时分别导航到新的网页或网站。
单击一个RadioButton控件时隐藏Panel控件,单击另一个RadioButton控件时显示Panel控件。
(3)添加一个网页,在页面中添加CheckBoxList控件,单击Button按钮时将CheckBoxList的选项写到ListBox中。
(4)添加一个网页,在页面中添加RadioButtonList控件,单击Button按钮时将RadioButtonList的选项写到ListBox中。
(5)添加一个网页,在页面中放入DropDownList控件,选择DropDownList控件的选项时导航到相应的网站。
(6)添加一个网页,在页面中添加TextBox、RequiredFieldValidator和CompareValidator控件,实现CompareValidator控件的Operator行为的Equal\GreaterThan等属性值的验证。
实验要求:
各个页面能够通过链接实现相互间的跳转。
三.实验步骤
(1)新建一个网站(或Web项目);
(2)在网站(或Web项目)中依次加入每个网页,并对每个网页进行设计。
(3)观察每个网页的运行结果。
四.实验结果
运行截图:
源代码:
1-1.Default.aspx:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>
DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:
//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//www.w3.org/1999/xhtml">
500px"bgcolor="#ccffcc">
TextBoxID="TextBox1"runat="server">
TextBox>
ButtonID="Button1"runat="server"Text="增?
加ó"onclick="Button1_Click"
Font-Names="微¢软è?
雅?
黑ú"/>
ButtonID="Button2"runat="server"Text="删?
除y"onclick="Button2_Click"
Font-Names="微¢软è?
雅?
黑ú"/>
ListBoxID="ListBox1"runat="server"Width="100px"
onselectedindexchanged="ListBox1_SelectedIndexChanged">
ListBox>
ButtonID="Button11"runat="server"Height="25px"onclick="Button11_Click"
style="margin-top:
0px"Text="首骸?
页?
"Width="52px"Font-Names="微¢软è?
雅?
黑ú"/>
LabelID="Label1"runat="server"Text="1">
Label>
ButtonID="Button5"runat="server"onclick="Button5_Click"Text="2"
Width="31px"/>
ButtonID="Button6"runat="server"onclick="Button6_Click"Text="3"
Width="31px"/>
ButtonID="Button7"runat="server"onclick="Button7_Click"Text="4"
Width="31px"/>
ButtonID="Button8"runat="server"onclick="Button8_Click"Text="5"
Width="31px"/>
ButtonID="Button9"runat="server"onclick="Button9_Click"Text="6"
Width="31px"/>
ButtonID="Button10"runat="server"onclick="Button10_Click"Text="下?
一?
页?
"
Width="53px"Font-Names="微¢软è?
雅?
黑ú"Height="25px"style="margin-top:
0px"/>