WiZard控件,修改密码
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WiZardDemo.aspx.cs" Inherits="WiZardDemo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>WiZard控件用法</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1" Width="400" OnActiveStepChanged="Wizard1_ActiveStepChanged">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="第一步" StepType="Start">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
请输入用户名:</td><td><asp:TextBox runat="server" ID="txtUserName"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
ErrorMessage="请输入用户名" ControlToValidate="txtUserName"></asp:RequiredFieldValidator> </asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="第二步" StepType="Step">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
你的密码提示问题:</td><td><asp:Label runat="server" ID="lbQuestion"></asp:Label></td></tr>
<tr><td>
你的密码提示答案:</td><td><asp:TextBox runat="server" ID="txtAnswer"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAnswer"
ErrorMessage="请输入密码提示答案"></asp:RequiredFieldValidator>
<asp:Label ID="lb_WrongAnswer" runat="server" ForeColor="Red" Text="答案错误" Visible="False"></asp:Label>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" StepType="Finish" Title="第三步">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
请输入新密码:</td><td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
请确认新密码:</td><td><asp:TextBox runat="server" ID="txtCPassword"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="请输入新密码"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCPassword"
Display="Dynamic" ErrorMessage="请确认新密码"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"
ControlToValidate="txtCPassword" ErrorMessage="两次密码不一致"></asp:CompareValidator>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep4" runat="server" StepType="Complete" Title="第四步">
恭喜,密码更改成功。
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
找回密码
</HeaderTemplate>
</asp:Wizard>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WiZardDemo.aspx.cs" Inherits="WiZardDemo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>WiZard控件用法</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1" Width="400" OnActiveStepChanged="Wizard1_ActiveStepChanged">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="第一步" StepType="Start">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
请输入用户名:</td><td><asp:TextBox runat="server" ID="txtUserName"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
ErrorMessage="请输入用户名" ControlToValidate="txtUserName"></asp:RequiredFieldValidator> </asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="第二步" StepType="Step">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
你的密码提示问题:</td><td><asp:Label runat="server" ID="lbQuestion"></asp:Label></td></tr>
<tr><td>
你的密码提示答案:</td><td><asp:TextBox runat="server" ID="txtAnswer"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAnswer"
ErrorMessage="请输入密码提示答案"></asp:RequiredFieldValidator>
<asp:Label ID="lb_WrongAnswer" runat="server" ForeColor="Red" Text="答案错误" Visible="False"></asp:Label>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" StepType="Finish" Title="第三步">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
请输入新密码:</td><td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
请确认新密码:</td><td><asp:TextBox runat="server" ID="txtCPassword"></asp:TextBox></td></tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="请输入新密码"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCPassword"
Display="Dynamic" ErrorMessage="请确认新密码"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"
ControlToValidate="txtCPassword" ErrorMessage="两次密码不一致"></asp:CompareValidator>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep4" runat="server" StepType="Complete" Title="第四步">
恭喜,密码更改成功。
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
找回密码
</HeaderTemplate>
</asp:Wizard>
</div>
</form>
</body>
</html>
Code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class WiZardDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
{
if (Wizard1.ActiveStepIndex == 1)//当用户进入找回密码第二步
{
//如果用户输入的是"admin"则提示用户输入"123456"
if (txtUserName.Text == "123")
{
lbQuestion.Text = "我的asdf";
}
else//如果用户输入的用户名不是"admin"则跳转到第一步
{
Wizard1.ActiveStepIndex = 0;
}
}
else if (Wizard1.ActiveStepIndex == 2)//当用户进入找回密码第三步
{
if (txtAnswer.Text == "asdf")
{
//用户的找回密码答案正确则修改数据库里的用户登录密码,代码略
}
else
{
Wizard1.ActiveStepIndex = 1;
lb_WrongAnswer.Visible = true;
}
}
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class WiZardDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
{
if (Wizard1.ActiveStepIndex == 1)//当用户进入找回密码第二步
{
//如果用户输入的是"admin"则提示用户输入"123456"
if (txtUserName.Text == "123")
{
lbQuestion.Text = "我的asdf";
}
else//如果用户输入的用户名不是"admin"则跳转到第一步
{
Wizard1.ActiveStepIndex = 0;
}
}
else if (Wizard1.ActiveStepIndex == 2)//当用户进入找回密码第三步
{
if (txtAnswer.Text == "asdf")
{
//用户的找回密码答案正确则修改数据库里的用户登录密码,代码略
}
else
{
Wizard1.ActiveStepIndex = 1;
lb_WrongAnswer.Visible = true;
}
}
}
}