How to use the Wizard control events in ASP.NET pages

If your project includes the Wizard control, described in the article: How to use the Wizard control steps in ASP.NET, you should take care about events raised by the control. The next table lists these events:

 

Event

Description

ActiveStepChangedThis event occurs when the Wizard control switches to a new step.
CancelButtonClick

This event occurs when the Cancel button is clicked. You can add it to every step by setting the Wizard.DisplayCancelButton property, because it is not shown by default. Usually, a Cancel button exits the wizard. If you don’t have any cleanup code to perform, just set the CancelDestinationPageUrl property, and the wizard will take care of the redirection automatically.

FinishButtonClickOccurs when the Finish button is clicked.
NextButtonClick and

PreviousButtonClick

This event occurs when the Next or Previous button is clicked on any step. It’s better to handle the ActiveStepChanged event, because there is more than one way to move from one step to the next.

SideBarButtonClickOccurs when a button in the sidebar area is clicked.

As software engineer you can use one of the two wizard programming models:

Commit-as-you-go:

You can use it in case when each wizard step wraps an atomic operation that can’t be reserved. For example, if you’re processing an order that involves a bank card authorization followed by a final purchase, you can’t allow the user to step back and edit credit card numbers. In this case, you should set the AllowReturn property to false on some or all steps and you should respond the ActiveStepChanged event to commit changes for each step.

Commit-at-the-end:

You can use this approach when each wizard step is collecting information for an operation that’s performed only at the end.   For example, if you’re collecting user information and plan to generate a new account once you have all the information, you’ll probably allow a user to make changes midway through the process. You should execute your code for generating the new account when the wizard is finished by reacting to the FinishButtonClick event.