ASP.Net/Asp Control/Wizard

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Basic Wizard

   <source lang="csharp">

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="BasicWizard" %> <!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>Untitled Page</title>

</head> <body>

   <form id="form1" runat="server">
      <asp:Wizard ID="Wizard1" 
                  runat="server" 
                  Width="467px" 
                  BackColor="#EFF3FB" 
                  BorderColor="#B5C7DE" 
                  BorderWidth="1px" 
                  Font-Names="Verdana"
                  CellPadding="5" 
                  ActiveStepIndex="0" 
                  Font-Size="Small" 
                  OnFinishButtonClick="Wizard1_FinishButtonClick">
             <WizardSteps>
               <asp:WizardStep ID="WizardStep1" runat="server" Title="Personal">

Personal Profile

                 Preferred Programming Language:
                 <asp:DropDownList ID="lstLanguage" runat="server">
                   <asp:ListItem>C#</asp:ListItem>
                   <asp:ListItem>VB .NET</asp:ListItem>
                   <asp:ListItem>J#</asp:ListItem>
                   <asp:ListItem>Java</asp:ListItem>
                   <asp:ListItem>C++</asp:ListItem>
                   <asp:ListItem>C</asp:ListItem>         
                 </asp:DropDownList>
                 
</asp:WizardStep> <asp:WizardStep ID="WizardStep2" runat="server" Title="Company">

Comany Profile

                 Number of Employees: <asp:TextBox ID="txtEmpCount" runat="server"></asp:TextBox>
Number of Locations:  <asp:TextBox ID="txtLocCount" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" Title="Software">

Software Profile

                 Licenses Required:
                 <asp:CheckBoxList ID="lstTools" runat="server">
                   <asp:ListItem>Visual Studio</asp:ListItem>
                   <asp:ListItem>Office</asp:ListItem>
                   <asp:ListItem>Windows 2003 Server</asp:ListItem>
                   <asp:ListItem>SQL Server 2005</asp:ListItem>
                   <asp:ListItem>BizTalk 2004</asp:ListItem>
                 </asp:CheckBoxList>
               </asp:WizardStep>
               <asp:WizardStep ID="Complete" runat="server" Title="Complete " StepType="Complete">
               Summary: <asp:Label ID="lblSummary" runat="server" Text="Label"></asp:Label>
               </asp:WizardStep>
             </WizardSteps>
          <SideBarStyle VerticalAlign="Top" />
            
           </asp:Wizard>
   </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; using System.Text; public partial class BasicWizard : System.Web.UI.Page {

 protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
 {
   StringBuilder sb = new StringBuilder();
   sb.Append("You chose: 
"); sb.Append("Programming Language: "); sb.Append(lstLanguage.Text); sb.Append("
Total Employees: "); sb.Append(txtEmpCount.Text); sb.Append("
Total Locations: "); sb.Append(txtLocCount.Text); sb.Append("
Licenses Required: "); foreach (ListItem item in lstTools.Items) { if (item.Selected) { sb.Append(item.Text); sb.Append(" "); } } sb.Append("
"); lblSummary.Text = sb.ToString(); }

}

</source>
   
  


Checkout wizard

   <source lang="csharp">

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Checkout" %> <!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>Chapter 20 Checkout Wizard</title>

</head> <body>

   <form id="form1" runat="server">
       Halloween Superstore - Checkout

<asp:Wizard ID="wizCheckout" runat="server" Width="739px" DisplayCancelButton="True" OnCancelButtonClick="wizCheckout_CancelButtonClick" > <WizardSteps> <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1: Contact Info"> Please enter your contact information:

                           First Name:
                           <asp:TextBox ID="txtFirstName" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator1" 
                               runat="server" 
                               ControlToValidate="txtFirstName"
                               ErrorMessage="First Name is required."></asp:RequiredFieldValidator>
                           Last name:
                           <asp:TextBox ID="txtLastName" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator2" 
                               runat="server" 
                               ControlToValidate="txtLastName"
                               ErrorMessage="Last Name is required."></asp:RequiredFieldValidator>
                           Email:
                           <asp:TextBox ID="txtEmail" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator3" 
                               runat="server" 
                               ControlToValidate="txtEmail"
                               ErrorMessage="Email is required."></asp:RequiredFieldValidator>
               </asp:WizardStep>
               <asp:WizardStep ID="WizardStep2" runat="server"
                    Title="Step 2: Shipping Method">
                   Please select a shipping method:

<asp:RadioButton ID="rdoUPSGround" runat="server" Checked="True" GroupName="ShipVia" Text="UPS Ground" />
<asp:RadioButton ID="rdoUPS2Day" runat="server" GroupName="ShipVia" Text="UPS Second Day" />
<asp:RadioButton ID="rdoFedEx" runat="server" GroupName="ShipVia" Text="Federal Express Overnight" />
</asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3: Credit Card Info"> Please enter your credit card information:

                           <asp:ListBox ID="lstCardType"
                               runat="server">
                               <asp:ListItem Selected="True"
                                   Value="VISA">Visa</asp:ListItem>
                               <asp:ListItem Value="MC">
                                   MasterCard</asp:ListItem>
                               <asp:ListItem Value="AMEX">
                                   American Express</asp:ListItem>
                           </asp:ListBox>
                           Card Number:
                           <asp:TextBox ID="txtCardNumber" runat="server"
                               Height="22px" Width="262px"></asp:TextBox>
                           Expiration Date:
                           <asp:DropDownList ID="ddlExpirationMonth"
                               runat="server">
                               <asp:ListItem Value="1">January</asp:ListItem>
                               <asp:ListItem Value="2">February</asp:ListItem>
                               <asp:ListItem Value="3">March</asp:ListItem>
                               <asp:ListItem Value="4">April</asp:ListItem>
                               <asp:ListItem Value="5">May</asp:ListItem>
                               <asp:ListItem Value="6">June</asp:ListItem>
                               <asp:ListItem Value="7">July</asp:ListItem>
                               <asp:ListItem Value="8">August</asp:ListItem>
                               <asp:ListItem Value="9">September</asp:ListItem>
                               <asp:ListItem Value="10">October</asp:ListItem>
                               <asp:ListItem Value="11">November</asp:ListItem>
                               <asp:ListItem Value="12">December</asp:ListItem>
                           </asp:DropDownList> 
                           <asp:DropDownList ID="ddlExpirationYear"
                               runat="server">
                           </asp:DropDownList>
               </asp:WizardStep>
           </WizardSteps>
       </asp:Wizard>
   </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 Checkout : System.Web.UI.Page {

   protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           wizCheckout.ActiveStepIndex = 0;
           int year = DateTime.Now.Year;
           for (; year < DateTime.Now.Year + 6; year++)
               ddlExpirationYear.Items.Add(year.ToString());
       }
   }
   protected void wizCheckout_CancelButtonClick(object sender, EventArgs e)
   {
       wizCheckout.ActiveStepIndex = 0;
       txtFirstName.Text = "";
       txtLastName.Text = "";
       txtEmail.Text = "";
       rdoUPSGround.Checked = true;
       rdoUPS2Day.Checked = false;
       rdoFedEx.Checked = false;
       lstCardType.SelectedIndex = 0;
       txtCardNumber.Text = "";
       ddlExpirationMonth.SelectedIndex = 0;
       ddlExpirationYear.SelectedIndex = 0;
   }

}

</source>
   
  


Checkout wizard (VB)

   <source lang="csharp">

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Checkout" %> <!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>Chapter 20 Checkout Wizard</title>

</head> <body>

   <form id="form1" runat="server">
       <asp:Wizard ID="wizCheckout" runat="server" ActiveStepIndex="0" 
           Width="739px" >
           <WizardSteps>
               <asp:WizardStep ID="WizardStep1" runat="server"
                   Title="Step 1: Contact Info">
                   Please enter your contact information:

First Name:
                           <asp:TextBox ID="txtFirstName" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator1" 
                               runat="server" 
                               ControlToValidate="txtFirstName"
                               ErrorMessage="First Name is required."></asp:RequiredFieldValidator>
Last name:
                           <asp:TextBox ID="txtLastName" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator2" 
                               runat="server" 
                               ControlToValidate="txtLastName"
                               ErrorMessage="Last Name is required."></asp:RequiredFieldValidator>
Email:
                           <asp:TextBox ID="txtEmail" runat="server"
                               Height="22px" Width="200px"></asp:TextBox>
                           <asp:RequiredFieldValidator
                               ID="RequiredFieldValidator3" 
                               runat="server" 
                               ControlToValidate="txtEmail"
                               ErrorMessage="Email is required."></asp:RequiredFieldValidator>
               </asp:WizardStep>
               <asp:WizardStep ID="WizardStep2" runat="server"
                    Title="Step 2: Shipping Method">
                   Please select a shipping method:

<asp:RadioButton ID="rdoUPSGround" runat="server" Checked="True" GroupName="ShipVia" Text="UPS Ground" />
<asp:RadioButton ID="rdoUPS2Day" runat="server" GroupName="ShipVia" Text="UPS Second Day" />
<asp:RadioButton ID="rdoFedEx" runat="server" GroupName="ShipVia" Text="Federal Express Overnight" />
</asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3: Credit Card Info"> Please enter your credit card information:

                               <asp:ListBox ID="lstCardType"
                                   runat="server">
                                   <asp:ListItem Selected="True"
                                       Value="VISA">Visa</asp:ListItem>
                                   <asp:ListItem Value="MC">
                                       MasterCard</asp:ListItem>
                                   <asp:ListItem Value="AMEX">
                                       American Express</asp:ListItem>
                               </asp:ListBox>
Card Number:
                           <asp:TextBox ID="txtCardNumber" runat="server"
                               Height="22px" Width="262px"></asp:TextBox>
Expiration Date:
                           <asp:DropDownList ID="ddlExpirationMonth"
                               runat="server">
                               <asp:ListItem Value="1">January</asp:ListItem>
                               <asp:ListItem Value="2">February</asp:ListItem>
                               <asp:ListItem Value="3">March</asp:ListItem>
                               <asp:ListItem Value="4">April</asp:ListItem>
                               <asp:ListItem Value="5">May</asp:ListItem>
                               <asp:ListItem Value="6">June</asp:ListItem>
                               <asp:ListItem Value="7">July</asp:ListItem>
                               <asp:ListItem Value="8">August</asp:ListItem>
                               <asp:ListItem Value="9">September</asp:ListItem>
                               <asp:ListItem Value="10">October</asp:ListItem>
                               <asp:ListItem Value="11">November</asp:ListItem>
                               <asp:ListItem Value="12">December</asp:ListItem>
                           </asp:DropDownList> 
                           <asp:DropDownList ID="ddlExpirationYear"
                               runat="server">
                           </asp:DropDownList>
               </asp:WizardStep>
           </WizardSteps>
       </asp:Wizard>
   </form>

</body> </html> File: Default.aspx.vb

Partial Class Checkout

   Inherits System.Web.UI.Page
   Protected Sub Page_Load(ByVal sender As Object, _
           ByVal e As System.EventArgs) Handles Me.Load
       If Not IsPostBack Then
           wizCheckout.ActiveStepIndex = 0
           Dim iYear As Integer
           For iYear = DateTime.Now.Year To DateTime.Now.Year + 5
               ddlExpirationYear.Items.Add(iYear.ToString())
           Next
       End If
   End Sub
   Protected Sub wizCheckout_CancelButtonClick(ByVal sender As Object, _
           ByVal e As System.EventArgs) Handles wizCheckout.CancelButtonClick
       wizCheckout.ActiveStepIndex = 0
       txtFirstName.Text = ""
       txtLastName.Text = ""
       txtEmail.Text = ""
       rdoUPSGround.Checked = True
       rdoUPS2Day.Checked = False
       rdoFedEx.Checked = False
       lstCardType.SelectedIndex = 0
       txtCardNumber.Text = ""
       ddlExpirationMonth.SelectedIndex = 0
       ddlExpirationYear.SelectedIndex = 0
   End Sub

End Class

</source>
   
  


how to set up and use a wizard.

   <source lang="csharp">

<%@ Page Language="C#"%> <!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>Simple Wizard</title>

</head> <body>

       <form id="form1" runat="server">

The simplest wizard!

           <asp:wizard ID="Wizard1" runat="server" HeaderText="Sample Wizard" DisplaySideBar="true">
           <SideBarStyle BackColor="lightcyan" />
           <HeaderStyle ForeColor="Info" />
           <wizardsteps>
               <asp:wizardstep runat="server" steptype="auto" id="step1">

First step

               </asp:wizardstep>
               <asp:wizardstep runat="server" steptype="auto" id="step2">

Second step

               </asp:wizardstep>
               <asp:wizardstep runat="server" steptype="auto" id="finish">

Final step

               </asp:wizardstep>
           </wizardsteps>
           </asp:wizard>    
       </form>

</body> </html>

</source>
   
  


Use WizardStep

   <source lang="csharp">

<%@ Page Language="VB" %> <!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>Untitled Page</title>

</head> <body>

   <form id="form1" runat="server">
       <asp:Wizard ID="Wizard1" runat="server">
           <WizardSteps>
               <asp:WizardStep ID="stpWakeUp" runat="server" Title="Step 1">

Wake Up

               </asp:WizardStep>
               <asp:WizardStep ID="stpShower" runat="server" Title="Step 2">

Shower

               </asp:WizardStep>
               <asp:WizardStep ID="stpTakeMeds" runat="server" Title="Step 3">

Take Meds

               </asp:WizardStep>
               <asp:WizardStep ID="stpBrushTeeth" runat="server" Title="Step 4">

Brush Teeth

               </asp:WizardStep>
               <asp:WizardStep ID="stpGetDressed" runat="server" Title="Step 5 ">

Get Dressed

               </asp:WizardStep>
               <asp:WizardStep ID="stpEatBreakfast" runat="server" Title="Step 6">

Eat Breakfast

               </asp:WizardStep>
               <asp:WizardStep ID="stpFinish" runat="server" Title="Step 7">

Finish

               </asp:WizardStep>
           </WizardSteps>
       </asp:Wizard>
   </form>

</body> </html>

</source>
   
  


Wizard ActiveStepIndex

   <source lang="csharp">

<%@ 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">
       <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>
                   
<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>
<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>
<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>
<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>
   </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 + "
"; this.FinishLabel.Text += "Your favorite color is " + this.DropDownList1.SelectedItem.Text + "
"; if (this.CheckBox1.Checked == true) { this.FinishLabel.Text += "And you are allergic to cats."; } else { this.FinishLabel.Text += "And you are not allergic to cats."; } } }

}

</source>
   
  


Wizard Demo

   <source lang="csharp">

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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 runat="server">

   <title>Wizard Demo</title>

</head> <body>

   <form id="form1" runat="server">
       <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" HeaderText="Menu Selector"
           Height="200px" Width="400px" OnFinishButtonClick="Wizard1_FinishButtonClick" OnNextButtonClick="Wizard1_NextButtonClick">
           <WizardSteps>
               <asp:WizardStep runat="server" Title="Step 1">
                   What is your eating preference?

<asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>Meat Eater</asp:ListItem> <asp:ListItem>Vegetarian</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> <asp:WizardStep runat="server" Title="Step 2"> Please select main course:

<asp:RadioButtonList ID="RadioButtonList2" runat="server"> <asp:ListItem>Chicken</asp:ListItem> <asp:ListItem>Fish</asp:ListItem> <asp:ListItem>Steak</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> <asp:WizardStep runat="server" Title="Step 3"> Please select main course:

<asp:RadioButtonList ID="RadioButtonList3" runat="server"> <asp:ListItem>Bread</asp:ListItem> <asp:ListItem>Salad</asp:ListItem> <asp:ListItem>Veggie Tray</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> <asp:WizardStep runat="server" Title="Step 4"> Please select beverage:

<asp:RadioButtonList ID="RadioButtonList4" runat="server"> <asp:ListItem>Coffee</asp:ListItem> <asp:ListItem>Water</asp:ListItem> <asp:ListItem>Wine</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> </WizardSteps> </asp:Wizard>
   </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; public partial class _Default : System.Web.UI.Page {

   protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
   {
       if (Wizard1.ActiveStepIndex == 0)
       {
           if (RadioButtonList1.SelectedValue == "Vegetarian")
           {
               Wizard1.ActiveStepIndex = 2;
           }
       }
       if (Wizard1.ActiveStepIndex == 1)
       {
           Wizard1.ActiveStepIndex = 3;
       }
   }
   protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
   {
       if (RadioButtonList1.SelectedValue == "Vegetarian")
       {
           Response.Write(
               "Your meal will be " +
               RadioButtonList3.SelectedValue +
               " and " +
               RadioButtonList4.SelectedValue);
       }
       else
       {
           Response.Write(
              "Your meal will be " +
              RadioButtonList2.SelectedValue +
              " and " +
              RadioButtonList4.SelectedValue);
       }
   }

}

</source>
   
  


Wizard finish button click event

   <source lang="csharp">

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default_aspx" %> <!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>Untitled Page</title>

</head> <body>

   <form id="form1" runat="server">
       <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" Width="308px">
           <WizardSteps>
               <asp:WizardStep runat="server" Title="Step 1">
                   Enter your name:
First Name <asp:TextBox runat="server" ID="txtFirstName"></asp:TextBox>
Last Name <asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
</asp:WizardStep> <asp:WizardStep runat="server" Title="Step 2"> Birthday:
<asp:Calendar runat="server" ID="Calendar1"></asp:Calendar> </asp:WizardStep> <asp:WizardStep runat="server" Title="Step 3"> Thank you for registering with us.</asp:WizardStep> </WizardSteps> </asp:Wizard>
 
       

</form>

</body> </html> File: Default.aspx.vb

Partial Class Default_aspx

   Inherits System.Web.UI.Page
   Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, _
       ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) _
       Handles Wizard1.FinishButtonClick
       Response.Write("You have registered as " & _
               txtFirstName.Text & _
               txtLastName.Text & "
") Response.Write("Birthday " & _ Calendar1.SelectedDate) Wizard1.Visible = False End Sub

End Class

</source>
   
  


Wizard history

   <source lang="csharp">

<%@ 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">

Wizard Demo

    <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">

Wake Up

         Rise and shine sleepy head.
        </asp:WizardStep>
        <asp:WizardStep ID="stpShower" runat="server" 
         Title="Step 2">

Shower

         Make it cold!
        </asp:WizardStep>
        <asp:WizardStep ID="stpTakeMeds" runat="server" 
         Title="Step 3" 
         AllowReturn="False">

Take Medicine

         Only do this once.
        </asp:WizardStep>
        <asp:WizardStep ID="stpBrushTeeth" runat="server" 
         Title="Step 4">

Brush Teeth

         Don"t forget to floss.
        </asp:WizardStep>
        <asp:WizardStep ID="stpGetDressed" runat="server" 
         Title="Step 5">

Get Dressed

         Got to look good.
        </asp:WizardStep>
        <asp:WizardStep ID="stpEatBreakfast" runat="server" 
         Title="Step 6">

Eat Breakfast

         The most important meal of the day.
        </asp:WizardStep>
        <asp:WizardStep ID="stpFinish" runat="server" 
         Title="Step 7" 
         StepType="Finish">

Out the Door

         Meet the world!
        </asp:WizardStep>
        <asp:WizardStep ID="stpComplete" runat="server" 
         StepType="Complete" 
         Title="Complete">

Complete!

         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>
    
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>

Active Step:  <asp:Label ID="lblActiveStep" runat="server" />
ActiveStepIndex:  <asp:Label ID="lblActiveStepIndex" runat="server" />
StepType:  <asp:Label ID="lblStepType" runat="server" />
Button Info:  <asp:Label ID="lblButtonInfo" runat="server" />

History <asp:Label ID="lblHistory" runat="server" />
   </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 + "
"; } 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); } } </source>


Wizard template

   <source lang="csharp">

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WizardTemplates" %> <!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>Untitled Page</title>

</head> <body>

   <form id="form1" runat="server">
      <asp:Wizard ID="Wizard1" 
                  runat="server" 
                  Width="467px" 
                  BackColor="#EFF3FB" 
                  BorderColor="#B5C7DE" 
                  BorderWidth="1px" 
                  Font-Names="Verdana"
                  CellPadding="5" 
                  ActiveStepIndex="0" 
                  Font-Size="Small" 
                  OnFinishButtonClick="Wizard1_FinishButtonClick">
             <WizardSteps>
               <asp:WizardStep ID="WizardStep1" runat="server" Title="Personal">

Personal Profile

                 Preferred Programming Language:
                 <asp:DropDownList ID="lstLanguage" runat="server">
                   <asp:ListItem>C#</asp:ListItem>
                   <asp:ListItem>VB .NET</asp:ListItem>
                   <asp:ListItem>J#</asp:ListItem>
                   <asp:ListItem>Java</asp:ListItem>
                   <asp:ListItem>C++</asp:ListItem>
                   <asp:ListItem>C</asp:ListItem>         
                 </asp:DropDownList>
                 
</asp:WizardStep> <asp:WizardStep ID="WizardStep2" runat="server" Title="Company">

Comany Profile

                 Number of Employees: <asp:TextBox ID="txtEmpCount" runat="server"></asp:TextBox>
                 Number of Locations: <asp:TextBox ID="txtLocCount" runat="server"></asp:TextBox>
               </asp:WizardStep>
               <asp:WizardStep ID="WizardStep3" runat="server" Title="Software">

Software Profile

                 Licenses Required:
                 <asp:CheckBoxList ID="lstTools" runat="server">
                   <asp:ListItem>Visual Studio</asp:ListItem>
                   <asp:ListItem>Office</asp:ListItem>
                   <asp:ListItem>Windows 2003 Server</asp:ListItem>
                   <asp:ListItem>SQL Server 2005</asp:ListItem>
                   <asp:ListItem>BizTalk 2004</asp:ListItem>
                 </asp:CheckBoxList>
               </asp:WizardStep>
               <asp:WizardStep ID="Complete" runat="server" Title="Complete " StepType="Complete">
                 Summary:<asp:Label ID="lblSummary" runat="server" Text="Label"></asp:Label>
                 
               </asp:WizardStep>
             </WizardSteps>
          <SideBarStyle VerticalAlign="Top" />
          
            <HeaderTemplate>
   Header Template -
   <%= Wizard1.ActiveStep.Title %>
 </HeaderTemplate>
          <StepNavigationTemplate>
          StepNavigationTemplate
<asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious" Text="Previous" /> <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Next" /> </StepNavigationTemplate> <StartNavigationTemplate> StartNavigationTemplate
<asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Next" /> </StartNavigationTemplate> <FinishNavigationTemplate> FinishNavigationTemplate
<asp:Button ID="FinishPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious" Text="Previous" /> <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" Text="Finish" /> </FinishNavigationTemplate> </asp:Wizard>
   </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; using System.Text; public partial class WizardTemplates : System.Web.UI.Page {

 protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
 {
   StringBuilder sb = new StringBuilder();
   sb.Append("You chose: 
"); sb.Append("Programming Language: "); sb.Append(lstLanguage.Text); sb.Append("
Total Employees: "); sb.Append(txtEmpCount.Text); sb.Append("
Total Locations: "); sb.Append(txtLocCount.Text); sb.Append("
Licenses Required: "); foreach (ListItem item in lstTools.Items) { if (item.Selected) { sb.Append(item.Text); sb.Append(" "); } } lblSummary.Text = sb.ToString(); }

}

</source>