dynamicweb4-4webform1.aspx
webform1.aspx.cs<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicweb4_4.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>个人信息</h3>
<table border="1">
<tr>
<td>入学年份:</td>
<td>
<asp:DropDownList ID="ddlYear" runat="server"></asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblTips" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
dynacmicweb4-5webform1.aspxusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dynamicweb4_4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
for (int i = 1980; i <= DateTime.Now.Year; i++)
{
ddlYear.Items.Add(i.ToString());
}
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblTips.Text = "";
if (ddlYear.SelectedIndex >= 0)
{
lblTips.Text += "入学年份:" + ddlYear.SelectedItem.Text + "<br>";
}
}
}
}
webform1.aspx.cs<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicweb4_5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>个人信息</h3>
<table border="1">
<tr>
<td>头像:</td>
<td>
<asp:DropDownList ID="ddlHeadImg" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlHeadImg_SelectedIndexChanged">
<asp:ListItem Value="1.png">企鹅</asp:ListItem>
<asp:ListItem Value="2.jpg">大头狗</asp:ListItem>
</asp:DropDownList>
<asp:Image ID="imgHead" runat="server" ImageUrl="~/Images/1.png" Width="40" Height="40" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblTips" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
dynamicweb4-6webform1.aspxusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dynamicweb4_5
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
protected void ddlHeadImg_SelectedIndexChanged(object sender, EventArgs e)
{
this.imgHead.ImageUrl = "~/Images/" + ddlHeadImg.SelectedValue;
}
}
}
webform1.aspx.cs<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicweb4_6.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>个人信息</h3>
<table border="1" style="text-align:center;">
<tr>
<td>用户名:</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>密码:</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>再次输入密码:</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" runat="server" Text="注册" OnClick="Button1_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblTips" runat="server" Text=""></asp:Label><br />
<asp:HyperLink ID="hlnkPI" runat="server" NavigateUrl="~/WebForm2.aspx" Visible="false">完善个人信息</asp:HyperLink>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
webform2.aspxusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dynamicweb4_6
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(TextBox1.Text))
{
lblTips.Text = "请输入用户名";
lblTips.ForeColor = System.Drawing.Color.Red;
TextBox1.Focus();
}
else if(String.IsNullOrEmpty(TextBox2.Text))
{
lblTips.Text = "请输入密码";
lblTips.ForeColor = System.Drawing.Color.Red;
TextBox2.Focus();
}
else if(String.IsNullOrEmpty(TextBox3.Text))
{
lblTips.Text = "请输入再次密码";
lblTips.ForeColor = System.Drawing.Color.Red;
TextBox3.Focus();
}
else if(TextBox2.Text != TextBox3.Text)
{
lblTips.Text = "两次输入密码不一致";
lblTips.ForeColor = System.Drawing.Color.Red;
TextBox2.Focus();
}
else
{
lblTips.Text = "注册成功!";
hlnkPI.Visible = true;
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="dynamicweb4_6.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>完善个人信息</h3>
</div>
</form>
</body>
</html>