Wizard Control in ASP.Net

Wizard control eliminates the need to design forms to execute a step-by-step process in the actual business flow. This simplifies the work of developers to design and write the code.

The control provides a mechanism that allows you to easily build the desired wizard as a collection of steps, add a new step, or reorder the steps. You don't have to write any infrastructure whatsoever for navigation or to persist user data between steps.

The asp, wizard is a control name and wizard steps is the parent element for the asp:wizardstep element.

<asp:wizard id="wizard1" runat="server">
  <wizardsteps>
    <asp:WizardStep runat="server" Title="Personal Information" StepType="Auto">
      <!-- Place the control here. -->
    </asp:WizardStep>
  </wizardsteps>
</asp:wizard>

There can be multiple wizard step that iterates from by form. The control can be placed in the wizard step tag.

The step is the enum type which has the attributes Auto, Complete, Finish, Start, and Step.

The first form will have the next button and all the subsequent forms will have the previous and next button.

The last wizard step tag should be defined as the complete step type.

There are events that are used to write the events on the controls in the wizard control.

  1. OnActiveStepChanged
  2. OnCancelButtonClick
  3. OnPreviousButtonClick
  4. OnNextButtonClick
  5. OnFinishButtonClick
  6. OnSideBarButtonClick

For example, the Finish button click event can be written on the server side like the following.

protected void OnFinish(object sender, WizardNavigationEventArgs e)  
{  
    WizardStepType t = Wizard1.WizardSteps[e.NextStepIndex].StepType;  
    if (t == WizardStepType.Finish)  
    {  
        // code here...  
    }  
}  

Wizard control properties
 

Template Description
FinishNavigationTemplate Specifies the navigation bar shown before the last page of the wizard; by default, the navigation bar contains the Previous and Finish buttons
HeaderTemplate Specifies the title bar of the wizard
SideBarTemplate Used to display content on the left side of the wizard control
StartNavigationTemplate Specifies the navigation bar for the first view in the wizard; by default, it contains only the Next button
StepNavigationTemplate Specifies the navigation bar for steps other than first, finish, or complete; by default, contains Previous and Next buttons


Wizard Style Properties
 

CancelButtonStyle Wizard Cancel button
FinishStepButtonStyle Wizard Finish button
FinishStepPreviousButtonStyle Wizard Previous button at the finishing step
HeaderStyle Wizard header
NavigationButtonStyle Navigation buttons
NavigationStyle Navigation area
NextStepButtonStyle Wizard Next button
PreviousStepButtonStyle Wizard Previous button
SideBarButtonStyle Buttons on the sidebar
StartStepNextButtonStyle Wizard Next button at the start step
StepStyle The Area where steps are displayed


Wizard Control Properties
 

Property Description
ActiveStep Returns the current wizard step object; the object is an instance of the WizardStep class
ActiveStepIndex Gets and sets the zero-based index of the current wizard step
DisplaySideBar Toggles the visibility of the sidebar; the default value is True
FinishStepButtonText Gets and sets the text for the Finish button
HeaderText Gets and sets the title of the wizard
NextStepButtonText Gets and sets the text for the Next button
PreviousStepButtonText Gets and sets the text for the Previous button

I have designed an example application for the Wizard control.

The wizard ActiveStep property can be set by the ActiveStepIndex="0" of the wizard control. The first form will have the next navigation control.

ActiveStep property

The next form can be navigated through the "Next" button or the user can jump into any wizard by clicking sidebar navigation control.

Next button

The Last form in the wizard will have the finish button. The user can identify the step by ActiveStepType in the finish button.

 Last form

Note. The properties, styles properties, and template table have been taken from the MSDN.


Similar Articles