Wizard Control - Annoyance Factor 1.2.3
So I’m playing around with the new ASP.NET Wizard control. Quite an impressive control to say the least, however within 1 hour I realized there were 3 annoyances that I think were implemented incorrectly.
1 – The wizard control has 2 events, NextButtonClick and FinishButtonClick, that are raised when the user’s clicking through the wizard. Both use the same event handler, and thus the same event args. The WizardNavigationEventArgs has a Cancel property that acts just like the CancelEventArgs. However – cancelling within the FinishButtonClick event when FinishDestinationPageUrl is set, doesn’t work – you still get redirected.
Workaround? Sure – but its not obvious and requires some comments inline so developers know whats going on.
private void FinishStep(object sender, WizardNavigationEventArgs e)
{
if (!Page.IsValid)
{
this.wizardControl.FinishDestinationPageUrl = string.Empty;
return;
}
this.wizardControl.FinishDestinationPageUrl = “AfterPage.aspx”;
}
The reason setting e.Cancel = true doesn’t work and clearing the destination page url does, is that the OnFinishButtonClick doesn’t care if you’ve cancelled or not, but redirects the user to the destination url as long as it exists. Now – if you don’t want to redirect to a page, but still show a completion message, you can create another wizard step and set it’s StypeType equal to “Complete”. When doing this, cancelling within the finish event works as expected.
2 – There are some instances that during a wizard, you have multiple paths based on the data entered in the current step. Being able to dynamically choose your next step works great in the Wizard control because it remembers what step you came from (a bonus feature that I wasn’t expecting!). However, setting the next active step isn’t one that “falls into the pit of success” that I’ve read / heard about a lot within the last week.
One would think the WizardNavigationEventArgs would allow you to set the next page index – but you cant… NextPageIndex is read-only. But the kicker, is they have an internal method (SetNextStepIndex) that is used by the Wizard control. While it would make most sense to allow the next page index to be set via the EventArgs since they have code in the OnBubbleEvent method to set ActiveStepIndex for you, but you have to resort to setting the ActiveStepIndex property on the wizard control itself.
3 – Okay, so this one falls into “why do we have multiple properties for the same (?) thing!” category. The Wizard control contains properties like StartNextButton[Text/Style/Type/ImageUrl] as well as StepNextButton[Text/Style/Type/ImageUrl]. When I was first configuring the wizard control, I didn’t realize that both of these existed and only set StepNextButton*. Much to my amazement, my 2 step wizard didn’t have what I just set it up to be. Needless to say I had to go digging through docs and intelli-sense to realize that, “Yes Virgina, there is a real santa claus.” A bit confusing and annoying if you ask me because if you want all your “Next” buttons to look the same you have to set 2n properties to do so!
Okay – enjoy your coding, I just had to get these few annoyances out!