Thursday, February 28, 2008

Here comes the Wizard! (1)

In this article I will be explaining in brief how to collect related data across steps through an easy navigation wizard how cool is this? Okay suppose you have this scenario:

Now to implement this I dragged the System.Web.UI.WebControles.Wizard control from my ToolBox, and then I added the following steps:

  • Select Product
  • Login
  • Register
  • Purchase
  • Confirmation
  • Forgot Password

Now because I wanted to customize navigation, I defined each step as a “Complete” step. To navigate from one step to the other you might want to write this:
protected void btnGo_Click(object sender, EventArgs e)
Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.Step1);
Where “Step1” is the ID I gave to the certain step I want to navigate to. Suppose you want to do some conditional navigation, you can use the OnActiveStepChanged event which fires
protected void OnActiveStepChanged(object sender, EventArgs e)
// If the ActiveStep is changing to Step3, check to see whether the
// SeparateShippingCheckBox is selected. If it is not, skip to the
// Finish step.
if (Wizard1.ActiveStepIndex == Wizard1.WizardSteps.IndexOf(this.Step3))
if (this.SeparateShippingCheckBox.Checked)

No comments: