第一范文网 - 专业文章范例文档资料分享平台

动态网页设计实训指导书

来源:用户分享 时间:2025/5/28 20:03:20 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

protected void Page_Load(object sender, EventArgs e) {

this.Title = \这是初次加载的页面!\ if (!IsPostBack) {

Image1.Visible = false; } else {

this.Title = \服务器回发后产生的刷新!\ Image1.Visible = true; } }

protected void Button1_Click(object sender, EventArgs e) { } }

任务二:

创建一个虚拟的用户登录页面,当输入的用户名为“张明”,密码为“654321”时,单击“登录”按扭跳转到Manage.aspx页面,并在Manage.aspx的页面显示出欢迎信息;当用户名或密码错误时弹出对话框提示“用户名或密码错误!”如图所示:

操作步骤:

(1).创建并设置页面:

创建站点,在站点中添加Login.aspx页面和Manage.aspx页面,Login.aspx页面中添加4行2列的表格进行页面布局,在表格的相应单元格中添加说明文章和控件。

各控件的属性设置如下: TexBox1的ID为txtName

30

TexBox2的ID为txtPwd

的TextMode为PassWord Button1的ID为btnLogin 的Text为登录 Button2的ID为btnReset 的Text为重写 (2)添加事件代码: using System;

using System.Configuration; using System.Data; using System.Linq; using System.Web;

using System.Web.Security; using System.Web.UI;

using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

}

protected void btnLogin_Click(object sender, EventArgs e) {

if (txtName.Text == \张明\ {

Response.Redirect(\ } else {

Response.Write(\用户名和密码错误!');\ } }

protected void btnReset_Click(object sender, EventArgs e) {

txtName.Text = \ txtPwd.Text = \ } }

31

Manage.aspx页面的事件代码:

using System;

using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web;

using System.Web.Security; using System.Web.UI;

using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;

public partial class Manage : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

Response.Write(\欢迎光临\ } }

任务三:

设计一个登录页面Login.aspx,如图所示,当在文本框中输入用户名,单击“提交”按扭时,跳转到网站子页面main.aspx,在子页面接收用户名,并判断用户名是否为空,当为空时弹出提示对话框,如图所示,单击“确定”按扭返回登录页面;当用户名不为空时,则在main.aspx页面输出欢迎信息“××,你好!”

32

操作步骤:

(1) 创建并设置登录页面(Login.aspx)

创建登录页面Login.aspx页面设置文本框ID为txtName,按扭ID为btnOk,Text为“提交”。

“提交”按扭的单击事件代码如下

using System;

using System.Configuration; using System.Data; using System.Linq; using System.Web;

using System.Web.Security; using System.Web.UI;

using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) { }

protected void btnOk_Click(object sender, EventArgs e)

{

Response.Redirect(\页面跳转,并传递参数变量 } }

(2).创建并设置子页面(main.aspx)

33

搜索更多关于: 动态网页设计实训指导书 的文档
动态网页设计实训指导书.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c803rc7wqwm0fvan2h1oh_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top