实验二ASPNET常用服务器控件淮海工学院.docx

上传人:b****6 文档编号:6673511 上传时间:2023-01-08 格式:DOCX 页数:35 大小:181KB
下载 相关 举报
实验二ASPNET常用服务器控件淮海工学院.docx_第1页
第1页 / 共35页
实验二ASPNET常用服务器控件淮海工学院.docx_第2页
第2页 / 共35页
实验二ASPNET常用服务器控件淮海工学院.docx_第3页
第3页 / 共35页
实验二ASPNET常用服务器控件淮海工学院.docx_第4页
第4页 / 共35页
实验二ASPNET常用服务器控件淮海工学院.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

实验二ASPNET常用服务器控件淮海工学院.docx

《实验二ASPNET常用服务器控件淮海工学院.docx》由会员分享,可在线阅读,更多相关《实验二ASPNET常用服务器控件淮海工学院.docx(35页珍藏版)》请在冰豆网上搜索。

实验二ASPNET常用服务器控件淮海工学院.docx

实验二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"/>


1-2.Default.aspx.cs:

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)

{

}

protectedvoidListBox1_SelectedIndexChanged(objectsender,EventArgse)

{

}

protectedvoidButton1_Click(objectsender,EventArgse)

{

ListBox1.Items.Add(newListItem(TextBox1.Text));

TextBox1.Text="";

}

protectedvoidButton2_Click(objectsender,EventArgse)

{

ListBox1.Items.RemoveAt(ListBox1.SelectedIndex);

}

protectedvoidButton11_Click(objectsender,EventArgse)

{

Response.Redirect("Default.aspx");

}

protectedvoidButton5_Click(objectsender,EventArgse)

{

Response.Redirect("Web2.aspx");

}

protectedvoidButton6_Click(objectsender,EventArgse)

{

Response.Redirect("Web3.aspx");

}

protectedvoidButton7_Click(objectsender,EventArgse)

{

Response.Redirect("Web4.aspx");

}

protectedvoidButton8_Click(objectsender,EventArgse)

{

Response.Redirect("Web5.aspx");

}

protectedvoidButton9_Click(objectsender,EventArgse)

{

Response.Redirect("Web6.aspx");

}

protectedvoidButton10_Click(objectsender,EventArgse)

{

Response.Redirect("Web2.aspx");

}

}

2-1.Web2.aspx:

<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Web2.aspx.cs"Inherits="Web2"%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

123px"bgcolor="#ccffcc">

PanelID="Panel1"runat="server"Height="118px">

LabelID="Label1"runat="server"Text="下?

面?

是?

两?

个?

超?

链ⅰ?

接ó:

阰"Font-Names="微¢软è?

雅?

黑ú">

Label>



LinkButtonID="LinkButton1"runat="server"onclick="LinkButton1_Click"

Font-Names="微¢软è?

雅?

黑ú">百悒?

度è一?

下?

LinkButton>



HyperLinkID="HyperLink1"runat="server"

NavigateUrl=""Font-Names="微¢软è?

雅?

黑ú">优?

酷á首骸?

页?

HyperLink>




Panel>

LabelID="Label2"runat="server"Text="面?

板?

颜?

色?

阰"Font-Names="微¢软è?

雅?

黑ú">

Label>

  

ButtonID="Bnt_c1"runat="server"Text="红ì色?

"onclick="Bnt_c1_Click"

Font-Names="微¢软è?

雅?

黑ú"Height="25px"style="margin-top:

4px"/>

 

ButtonID="Bnt_c2"runat="server"Text="绿ì色?

"onclick="Bnt_c2_Click"

Font-Names="微¢软è?

雅?

黑ú"Height="25px"/>

 

ButtonID="Bnt_c3"runat="server"Text="还1原-"onclick="Bnt_c3_Click"

Font-Names="微¢软è?

雅?

黑ú"Height="25px"/>

LabelID="Label3"runat="server"Text="字?

体?

大洙?

小?

阰"Font-Names="微¢软è?

雅?

黑ú">

Label>

  

ButtonID="Bnt_s1"runat="server"Height="29px"Text="小?

"

onclick="Bnt_s1_Click"Font-Names="微¢软è?

雅?

黑ú"Width="30px"/>

 

ButtonID="Bnt_s2"runat="server"Text="中D"onclick="Bnt_s2_Click"

Font-Names="微¢软è?

雅?

黑ú"/>

 

ButtonID="Bnt_s3"runat="server"Text="大洙?

onclick="Bnt_s3_Click"

Font-Names="微¢软è?

雅?

黑ú"/>





RadioButtonID="Rb1"runat="server"GroupName="AA"Text="显?

示?

"

oncheckedchanged="Rb1_CheckedChanged"Checked="True"AutoPostBack="True"

Font-Names="微¢软è?

雅?

黑ú"/>

    

RadioButtonID="Rb2"runat="server"GroupName="AA"Text="隐皌藏?

"

oncheckedchanged="Rb2_CheckedChanged"AutoPostBack="True"

Font-Names="微¢软è?

雅?

黑ú"/>


                                 



                                    

ButtonID="Button11"runat="server"Height="25px"onclick="Button11_Click"

style="margin-top:

0px"Text="首骸?

页?

"Width="52px"Font-Names="微¢软è?

雅?

黑ú"/>

 

ButtonID="Button3"runat="server"onclick="Button3_Click"

style="margin-left:

0px"Text="上?

一?

页?

"Width="53px"Font-Names="微¢软è?

雅?

黑ú"

Height="25px"/>

 

ButtonID="Button4"runat="server"onclick="Button4_Click"Text="1"

Width="31px"/>

 

LabelID="Label4"runat="server"Text="2">

Label>

 

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"/>

2-2.Web2.aspx.cs:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Web;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

publicpartialclassWeb2:

System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

}

protectedvoidLinkButton1_Click(objectsender,EventArgse)

{

Response.Redirect("");

}

protectedvoidBnt_c1_Click(objectsender,EventArgse)

{

Panel1.BackColor=System.Drawing.Color.Red;

}

protectedvoidBnt_c2_Click(objectsender,EventArgse)

{

Panel1.BackColor=System.Drawing.Color.Green;

}

protectedvoidBnt_c3_Click(objectsender,EventArgse)

{

Panel1.BackColor=System.Drawing.Color.Transparent;

}

protectedvoidBnt_s1_Click(objectsender,EventArgse)

{

Panel1.Font.Size=8;

}

protectedvoidBnt_s2_Click(objectsender,EventArgse)

{

Panel1.Font.Size=12;

}

protectedvoidBnt_s3_Click(objectsender,EventArgse)

{

Panel1.Font.Size=15;

}

protectedvoidRb1_CheckedChanged(objectsender,EventArgse)

{

Panel1.Visible=true;

}

protectedvoidRb2_CheckedChanged(objectsender,EventArgse)

{

Panel1.Visible=false;

}

protectedvoidButton11_Click(objectsender,EventArgse)

{

Response.Redirect("Default.aspx");

}

protectedvoidButton3_Click(objectsender,EventArgse)

{

Response.Redirect("Default.aspx");

}

protectedvoidButton4_Click(objectsender,EventArgse)

{

Response.Redirect("Default.aspx");

}

protectedvoidButton6_Click(o

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1