Helper Method for ASP.NET Wizard Controls

I enjoy working with the ASP.NET Wizard control – it’s one of the more useful controls available, and there always seems to be a place for a wizard in the custom apps I’ve written. Over time I’ve developed a helper method that makes it easier to do non-linear jumps from step to step.

GetIndexFromStep(WizardStepBase step)

Often, in a NextButtonClick event handler for a Wizard, you need to figure out what the current step is that you are on, based on the WizardNavigationEventArgs e.CurrentStepIndex property. Here is a helper method to enable you to do that:

You can also package it up as an extension method (.NET 3.5) off of the Wizard or WizardStepBase object:

If you’ve given your wizard steps specific IDs, then you can use them strongly typed in a NextButtonClick event: