Wizard Demo : Wizard « Asp Control « ASP.Net






Wizard Demo

<%@ 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">
    <div>
        <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?<br />
                    <br />
                    <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:<br />
                    <br />
                    <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:<br />
                    <br />
                    <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:<br />
                    <br />
                    <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>
    
    </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;

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);
        }
    }
}

 








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 ActiveStepIndex
7.Wizard history
8.Use WizardStep
9.Wizard finish button click event