Sunday, August 28, 2011

ASP.Net Wizard Control Example

Wizard.aspx
-------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Wizard.aspx.cs" Inherits="Wizard" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="sc1" runat="server"></asp:ScriptManager>
    <table border="1">
    <tr>
    <td>
    
    
     <asp:Wizard ID="AddPropertyWizard" runat="server" ActiveStepIndex="0" OnFinishButtonClick="AddPropertyWizard_FinishButtonClick"
            OnNextButtonClick="AddPropertyWizard_NextButtonClick" StepPreviousButtonImageUrl="~/Images/btn_more.jpg"
            OnPreviousButtonClick="AddPropertyWizard_PreviousButtonClick" Width="98%" margin-left="10px"
            DisplaySideBar="False">
            <StepPreviousButtonStyle CssClass="btn_previous" Width="70px" ForeColor="white" Font-Names="verdana"
                Height="22px" />
            <StepNextButtonStyle CssClass="btn_next" Width="75px" ForeColor="White" Font-Names="verdana"
                Height="22px" />
            <FinishCompleteButtonStyle CssClass="btn_previous" Width="85px" ForeColor="white"
                Font-Names="verdana" />
            <FinishPreviousButtonStyle CssClass="btn_previous" Width="85px" Height="22px" ForeColor="white"
                Font-Names="verdana" />
            <StartNextButtonStyle CssClass="btn_next" Width="70px" Height="22px" ForeColor="White"
                Font-Names="verdana" />
               
            <WizardSteps>
            
                <asp:WizardStep ID="WizardStep1" runat="server">
                <table>
                <tr>
                <td>UserName:</td>
                <td>
                <asp:TextBox ID="txtuser" runat="server"></asp:TextBox>
                </td>
                </tr>
                <tr>
                <td> Password:</td>
               <td>
               <asp:TextBox ID="txtpass" runat="server"></asp:TextBox>
                </td>
                </tr>
                </table>    
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep2" runat="server">
               <table>
                <tr>
                <td>Address:</td>
                <td>
                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
                </td>
                </tr>
                <tr>
                <td>Phone:</td>
                
                <td>
                <asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
                
                </td>
                </tr>
                </table> 
                </asp:WizardStep>
               <asp:WizardStep ID="WizardStep3" runat="server">
               <table>
                <tr>
                <td> Office:</td>
               
                <td>
               <asp:TextBox ID="txtOffice" runat="server"></asp:TextBox>
                </td>
                </tr>
                
                <tr>
                <td> Map:</td>
                
                <td>
               <asp:TextBox ID="txtMap" runat="server"></asp:TextBox>
                
                </td>
                </tr>
                </table> 
                </asp:WizardStep>
                </WizardSteps>
                </asp:Wizard>
               
             </td>
    </tr>
    </table>
</div>
<div>
<table>
<tr>
<td>
<asp:Label ID="lbl1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl2" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl3" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl4" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl5" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl6" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
    </form>
</body>
</html>
-------------------------------------------------------------
Wizard.aspx.cs
-----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Wizard : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void AddPropertyWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        int Index = Convert.ToInt32(AddPropertyWizard.ActiveStepIndex);
        switch (Index)
        {
            case 0:
                AddPropertyWizard.ActiveStepIndex = 1;
                 break;
            case 1:
                AddPropertyWizard.ActiveStepIndex = 2;
                  break;
            case 2:
                AddPropertyWizard.ActiveStepIndex = 3;
                break;
        }
    }
    protected void AddPropertyWizard_PreviousButtonClick(object sender, EventArgs e)
    {
        int Index = Convert.ToInt32(AddPropertyWizard.ActiveStepIndex);
        switch (Index)
        {
            case 1:
                AddPropertyWizard.ActiveStepIndex = 0;
                break;
            case 2:
                AddPropertyWizard.ActiveStepIndex = 1;
                break;
            case 3:
                AddPropertyWizard.ActiveStepIndex = 2;
                break;
        }
    }
  
    protected void AddPropertyWizard_FinishButtonClick(object sender, EventArgs e)
    {
        lbl1.Text = "The UserName is :" + txtuser.Text + "\n";
        lbl2.Text = "The Password is:" + txtpass.Text + "\n";
        lbl3.Text = "The Address is:" + txtAddress.Text + "\n";
        lbl4.Text = "The Phone is:" + txtPhone.Text + "\n";
        lbl5.Text = "The Office is:" + txtOffice.Text + "\n";
        lbl6.Text = "The Map is:" + txtMap.Text + "\n";
    }
}


output:


wizard

1 comments:

Anonymous said...

Windows Forms KetticWizard control

Post a Comment