Wizard ActiveStepIndex : Wizard « Asp Control « ASP.Net






Wizard ActiveStepIndex

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WizardForm" %>

<!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 Form</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" Height="265px" Width="406px" OnActiveStepChanged="Wizard1_ActiveStepChanged" DisplaySideBar="False" >
            <WizardSteps>
                <asp:WizardStep runat="server" Title="Enter text in text box">
                    <asp:Label ID="Label1" runat="server" Text="Step 1"></asp:Label>
                    <br />
                    <asp:Label ID="Label2" runat="server" Text="Your Dog's Name is:"></asp:Label>
                    <asp:TextBox ID="DogName" runat="server"></asp:TextBox>
                </asp:WizardStep>
                <asp:WizardStep runat="server" Title="Select from drop-down list">
                    <asp:Label ID="Label3" runat="server" Text="Step 2"></asp:Label>
                    <br />
                    <asp:Label ID="Label4" runat="server" Text="Your Favorite Color:"></asp:Label>
                    <asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem>Red</asp:ListItem>
                        <asp:ListItem>Green</asp:ListItem>
                        <asp:ListItem>Blue</asp:ListItem>
                    </asp:DropDownList>
                </asp:WizardStep>
                <asp:WizardStep runat="server" Title="Select or clear a check box">
                    <asp:Label ID="Label5" runat="server" Text="Step 3"></asp:Label>
                    <br />
                    <asp:CheckBox ID="CheckBox1" runat="server" Text="I am allergic to cats" />
                </asp:WizardStep>
                <asp:WizardStep runat="server" Title="Finish">
                    <asp:Label ID="Label6" runat="server" Text="Step 4"></asp:Label>
                    <br />
                    <asp:Label ID="FinishLabel" runat="server"></asp:Label>
                </asp:WizardStep>
            </WizardSteps>
            <StepStyle Font-Size="0.8em" ForeColor="#333333" />
            <SideBarStyle BackColor="Yellow" Font-Size="0.9em" VerticalAlign="Top" />
            <SideBarButtonStyle BackColor="Yellow" Font-Names="Verdana" ForeColor="White" />
            <HeaderStyle BackColor="#284E98" 
                         BorderColor="#EFF3FB" 
                         BorderStyle="Solid" 
                         BorderWidth="2px"
                         Font-Bold="True" 
                         Font-Size="0.9em" 
                         ForeColor="White" 
                         HorizontalAlign="Center" />
            <NavigationButtonStyle BackColor="White" 
                                   BorderColor="Yellow" 
                                   BorderStyle="Solid"
                                   BorderWidth="1px" 
                                   Font-Names="Verdana" 
                                   Font-Size="0.8em" 
                                   ForeColor="#284E98" />
        </asp:Wizard>
    
    </div>
    </form>
</body>
</html>

File: Default.aspx.cs

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 WizardForm : System.Web.UI.Page
{
  protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
  {
    if ( this.Wizard1.ActiveStepIndex==3 )
    {
      this.FinishLabel.Text =
        "Your Dog's Name is " +
        this.DogName.Text + "<br />";
      this.FinishLabel.Text +=
        "Your favorite color is " +
        this.DropDownList1.SelectedItem.Text +
        "<br />";
      if (this.CheckBox1.Checked == true)
      {
        this.FinishLabel.Text +=
          "And you are allergic to cats.";
      }
      else
      {
        this.FinishLabel.Text +=
          "And you are <b>not</b> allergic to cats.";
      }
    }
  }
}

 








Related examples in the same category

1.Basic Wizard
2.how to set up and use a wizard.
3.Wizard template
4.Checkout wizard
5.Checkout wizard (VB)
6.Wizard history
7.Use WizardStep
8.Wizard Demo
9.Wizard finish button click event