Wizard history
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Wizard Demo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Wizard Demo</h1>
<asp:Wizard ID="wzrdMorning" runat="server"
DisplayCancelButton="True"
OnCancelButtonClick="wzrdMorning_CancelButtonClick"
OnActiveStepChanged="wzrdMorning_ActiveStepChanged"
OnFinishButtonClick="Button_Click"
OnNextButtonClick="Button_Click"
OnPreviousButtonClick="Button_Click"
OnSideBarButtonClick="Button_Click"
BackColor="#E6E2D8"
BorderColor="#999999"
BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" >
<WizardSteps>
<asp:WizardStep ID="stpWakeUp" runat="server"
Title="Step 1"
StepType="Start">
<h2>Wake Up</h2>
Rise and shine sleepy head.
</asp:WizardStep>
<asp:WizardStep ID="stpShower" runat="server"
Title="Step 2">
<h2>Shower</h2>
Make it cold!
</asp:WizardStep>
<asp:WizardStep ID="stpTakeMeds" runat="server"
Title="Step 3"
AllowReturn="False">
<h2>Take Medicine</h2>
Only do this once.
</asp:WizardStep>
<asp:WizardStep ID="stpBrushTeeth" runat="server"
Title="Step 4">
<h2>Brush Teeth</h2>
Don't forget to floss.
</asp:WizardStep>
<asp:WizardStep ID="stpGetDressed" runat="server"
Title="Step 5">
<h2>Get Dressed</h2>
Got to look good.
</asp:WizardStep>
<asp:WizardStep ID="stpEatBreakfast" runat="server"
Title="Step 6">
<h2>Eat Breakfast</h2>
The most important meal of the day.
</asp:WizardStep>
<asp:WizardStep ID="stpFinish" runat="server"
Title="Step 7"
StepType="Finish">
<h2>Out the Door</h2>
Meet the world!
</asp:WizardStep>
<asp:WizardStep ID="stpComplete" runat="server"
StepType="Complete"
Title="Complete">
<h2>Complete!</h2>
Your morning routine is now complete.
</asp:WizardStep>
</WizardSteps>
<StepStyle BackColor="#F7F6F3"
BorderColor="#E6E2D8"
BorderStyle="Solid"
BorderWidth="2px" />
<SideBarStyle BackColor="#1C5E55"
Font-Size="0.9em"
VerticalAlign="Top" />
<NavigationButtonStyle BackColor="White"
BorderColor="#C5BBAF"
BorderStyle="Solid"
BorderWidth="1px"
Font-Names="Verdana"
Font-Size="0.8em"
ForeColor="#1C5E55" />
<SideBarButtonStyle ForeColor="White" />
<HeaderStyle BackColor="#666666"
BorderColor="#E6E2D8"
BorderStyle="Solid"
BorderWidth="2px"
Font-Bold="True"
Font-Size="0.9em"
ForeColor="White"
HorizontalAlign="Center" />
</asp:Wizard>
<br />
Select a step:
<asp:DropDownList ID="DropDownList1"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList>
<br />
<br />
Active Step:
<asp:Label ID="lblActiveStep" runat="server" />
<br />
ActiveStepIndex:
<asp:Label ID="lblActiveStepIndex" runat="server" />
<br />
StepType:
<asp:Label ID="lblStepType" runat="server" />
<br />
Button Info:
<asp:Label ID="lblButtonInfo" runat="server" />
<br />
<br />
<u>History</u>
<asp:Label ID="lblHistory" runat="server" />
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
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;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void wzrdMorning_ActiveStepChanged(object sender, EventArgs e)
{
lblActiveStep.Text = wzrdMorning.ActiveStep.Title;
lblActiveStepIndex.Text = wzrdMorning.ActiveStepIndex.ToString();
lblStepType.Text = wzrdMorning.ActiveStep.StepType.ToString();
ICollection steps = wzrdMorning.GetHistory();
string str = "";
foreach (WizardStep step in steps)
{
str += step.Title + "<br/>";
}
lblHistory.Text = str;
}
protected void Button_Click(object sender, WizardNavigationEventArgs e){
string str = "Current Index: " +
e.CurrentStepIndex.ToString() +
". Next Step: " + e.NextStepIndex.ToString();
lblButtonInfo.Text = str;
}
protected void wzrdMorning_CancelButtonClick(object sender, EventArgs e){
lblActiveStep.Text = "";
lblActiveStepIndex.Text = "";
lblStepType.Text = "";
lblButtonInfo.Text = "Canceled";
wzrdMorning.Visible = false;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
DropDownList ddl = (DropDownList)sender;
int index = ddl.SelectedIndex;
WizardStepBase step = wzrdMorning.WizardSteps[index];
wzrdMorning.MoveTo(step);
}
}
Related examples in the same category