当前位置:文档之家› ASP net程序设计实验报告四

ASP net程序设计实验报告四

ASP net程序设计实验报告四
ASP net程序设计实验报告四

Xxxxxxxxxxxxxxxxxxx 实验报告

实验课程名称:https://www.doczj.com/doc/fb13117260.html,程序设计

实验项目名称:https://www.doczj.com/doc/fb13117260.html, 服务器控件

专业班级:xxxxxxxxxxx

学号:xxxxxxxxxxxxx

姓名:xxxxxxxxxxx

指导教师:xxxxxxxx

实验四 https://www.doczj.com/doc/fb13117260.html, 服务器控件

【实验目的】

(1)熟悉用户控件的创建技术,掌握用户控件的属性、事件、方法的定义和使用。

(2)学会利用自定义用户控件制作导航条和用户登录控件。

【实验内容及步骤】

(1)新建名字为ServerControlExperiment网站。

(2)在default.aspx页面中,添加1个TextBox控件、2个Button控件、一个ListBox控件,如图所示。将2个Button控件的Text属性分别改为“增加”和“删除”。当单击【增加】按钮时,将TextBox文本框中的输入值添加到ListBox中,但单击【删除】按钮时,删除ListBox中当前选定项。

protected void Button1_Click(object sender, EventArgs e)

{ListBox1.Items.Add(TextBox1.Text.ToString().Trim());

TextBox1.Focus();

TextBox1.Text = "";}

protected void Button2_Click(object sender, EventArgs e)

{for (int i = ListBox1.Items.Count - 1; i >= 0; i--)

{if(ListBox1.Items[i].Selected)

ListBox1.Items.Remove(ListBox1.Items[i].Value);}}

(3)添加一个网页,要求将Label控件、LinkButton控件、HyperLink控件放在Panel控件中,当单击一组Button按钮时改变Panel控件的背景色,单击另一组Button控件时改变Panel控件中文字的大小。单击LinkButton和HyperLink控件时分别导航到新的网页或网站。单击RadioButton控件时隐藏Panel控件,单击另一个RadioButton控件时显示Panel控件。如图所示。

Default2.aspx页面代码:


baidu

runat="server">HyperLink

 


Text="隐藏Panel控件"GroupName="a1"/>

Text="显示Panel控件"GroupName="a1"/>

Default2.cs页面代码:

public partial class Default2 : System.Web.UI.Page

{protected void Button1_Click(object sender, EventArgs e)

{this.Panel1.BackColor = System.Drawing.Color.LightSteelBlue;}

protected void Button2_Click(object sender, EventArgs e)

{this.Panel1.Font.Size = https://www.doczj.com/doc/fb13117260.html,rger;} protected void RadioButton1_CheckedChanged(object sender, EventArgs e)

{if (RadioButton1.Checked)

{this.Panel1.Visible = false;}}

protected void RadioButton2_CheckedChanged(object sender, EventArgs e)

{if (RadioButton2.Checked)

{this.Panel1.Visible = true;}}}

(4)添加一个网页,在MultiView控件添加3个View控件,在每个View控件中各添加Image控件,再添加3个RadioButton控件切换各个View视图,每个View视图显示不同的图像。

Default3.aspx页面代码:

 


 

ImageUrl="~/yuan.jpg"Width="200px"/>

 

ImageUrl="~/ju.jpg"Width="200px"/>
选择显示的形状

AutoPostBack="True"

onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">

三角形

圆形

矩形

Default3.cs页面代码:

public partial class Default3 : System.Web.UI.Page

{protected void Page_Load(object sender, EventArgs e)

{if (Request.QueryString["id"] != null)

{MultiView1.ActiveViewIndex = Convert.ToInt32(Request.QueryString["id"]);}} protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)

{MultiView1.ActiveViewIndex = RadioButtonList1.SelectedIndex;}}

(5)添加一个网页,在页面中添加AdRotator控件,链接XML广告数据源,实现广告图像显示,当单击广告图像时导航到相应的网页。

Default4.aspx页面代码:

DataFile="~/XMLFile.xml">

XMLFile.xml页面代码:

https://www.doczj.com/doc/fb13117260.html,/img/bdlogo.gif

https://www.doczj.com/doc/fb13117260.html,/

AD for haizei,Ltd.Web site

100

(6)添加一个网页,在页面中添加CheckBoxList控件,单击Button按钮时将CheckBoxList的选项写到ListBox中。

Default5.aspx页面代码:

请选择你要考试的科目:

RepeatDirection="Horizontal">

政治

英语

数学

专业课

BorderStyle="Outset"BorderWidth="1px"/>

Default5.cs代码:

public partial class Default5 : System.Web.UI.Page

{protected void Button1_Click(object sender, EventArgs e)

{ListBox1.Items.Clear();

for (int i = 0; i < CheckBoxList1.Items.Count; i++)

{if (CheckBoxList1.Items[i].Selected)

{ ListBox1.Items.Add(CheckBoxList1.Items[i].Text); }}}}

(7)添加一个网页,在页面中添加RadioButtonList控件,单击Button按钮时将CheckBoxList的选项写到ListBox中。

Default6.aspx页面代码:

选择你要考试的科目:

AutoPostBack="True"Width="216px">

政治

英语

数学

专业课

            

           

  

Width="218px">

Default6.cs代码:

public partial class Default6 : System.Web.UI.Page

{protected void Button1_Click(object sender, EventArgs e)

{ListBox1.Items.Clear();

if (RadioButtonList1.SelectedItem.Selected)

{ ListBox1.Items.Add(RadioButtonList1.SelectedItem.Text); }}}

(8)添加一个网页,选择DropDownList控件的选项时导航到相应的网站。

Default7.aspx页面代码:

Height="72px"onselectedindexchanged="DropDownList1_SelectedIndexChanged">

百度

新浪



Default7.cs代码:

public partial class Default7 : System.Web.UI.Page

{protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{switch (DropDownList1.SelectedItem.Text.Trim())

{case"百度":

Response.Redirect("https://www.doczj.com/doc/fb13117260.html,/");

break;

case"新浪":

Response.Redirect("https://www.doczj.com/doc/fb13117260.html,/");

break;}}}

(9)添加一个网页,在页面中添加TextBox、RequiredFiledValidator和CompareValidator控件,实现CompareValidator控件的Operator行为的Equal、GreaterThan等属性值得验证。

Default8.aspx页面代码:

请注册用户

姓 名:

Width="150px">

ControlToValidate="TextBox1"ErrorMessage="请输入用户名"ValidationGroup="a1" Width="14px">*

学 号:

Width="150px"> 

密 码:

ValidationGroup="a1"Width="150px">

ControlToValidate="TextBox3"ErrorMessage="请输入密码"

ValidationGroup="a1">*

确认密码:

ValidationGroup="a1"Width="134px">

ControlToCompare="TextBox3"ControlToValidate="TextBox4"ErrorMessage="确认密码不一致"ValidationGroup="a1">确认密码不一致 

            

            

ValidationGroup="a1"BorderStyle="Outset"BorderWidth="1px"/>

ValidationGroup="a1"/>

Default8.cs代码:

public partial class Default8 : System.Web.UI.Page

{protected void Button1_Click(object sender, EventArgs e)

{Label1.Text = "";

if (Page.IsValid)

{Label1.Text = "登入成功";}

else

{Label1.Text = "登入失败";}}}

【实验总结】

通过本次的上机实验,我熟悉了xxxxxxxxxxxxxxxxxxxxxxxx

电子实验报告

电子实验报告 篇一:电子实验报告 实验2 一阶电路的过渡过程 实验2.1 电容器的充电和放电 一、实验目的 1.充电时电容器两端电压的变化为时间函数,画出充电电压曲线图。 2.放电时电容器两端电压的变化为时间函数,画出放电电压曲线图。 3.电容器充电电流的变化为时间函数,画出充电电流曲线图。 4.电容器放电电流的变化为时间函数,画出放电电流的曲线图。 5.测量RC电路的时间常数并比较测量值与计算值。 6.研究R和C的变化对RC电路时间常数的影响。 二、实验器材 双踪示波器 1台 信号发生器 1台 0.1μF和0.2μF电容各1个 1KΩ和2KΩ电阻各1个 三、实验准备 在图2-1和图2-2所示的RC电路中,时间常数τ可以

用电阻R和电容C 的乘机来计算。因此 τ=R 图2-1 电容器的充电电压和放电电压 在电容器充电和放电的过程中电压和电流都会发生变化,只要在充电或放电曲线图上确定产生总量变化63 %所需要的时间,就能测出时间常数。 用电容器充电电压曲线图测量时间常数的另一种方法是,假定在整个充电期间电容器两端的电压以充电时的速率持续增加,当增大到充满电的电压值时,这个时间间隔就等于时间常数。或者用电容器放电电压曲线图来测量,假定在整个放电期间电容器两端的电压以初放电时的速率持续减少,当减少到零时,这个时间间隔也等于时间常数。 在图2-2中流过电阻R的电流IR与流过电容器的电流IC相同,这个电流可用电阻两端的电压VR除以电阻R来计算。因此 IR=Ic=VR /R 图2-2 电容器的充电电流和放电电流 四、实验步骤 1.实验图如下 2.用曲线图测量RC电路的时间常数τ。 τ=121.6799μs

Web程序设计实验报告

Web程序设计实验报告 姓名:冯刚 学号:200905030324 班级:计科3班

Html代码: 1.首页代码 无标题文档