ASP.NET Wizard Step

September 19, 2012    ASP.NET blog school

An assignment for my Web Application Development class. For this assignment I had to create two forms that both use validation groups to validate the fields. One of the forms must use either Wizard Steps or Multiview. I chose Wizard Steps.


Validation was not working for the wizard steps even though everything was coded perfectly.

<asp:WizardStep id=”wds_2″ runat=”server” title=”Account Info”>
<asp:Label ID=”lbl_username” runat=”server” Text=”Username: ” AssociatedControlID=”txt_username” />
<asp:TextBox ID=”txt_username” runat=”server” />
<asp:RequiredFieldValidator ID=”rfv_username” runat=”server” ControlToValidate=”txt_username” display=”Dynamic” Text=”Empty value” ErrorMessage=”Please enter username.” ValidationGroup=”info_form” />
No validation for the form.
In wizard step, the next and previous buttons are automatically created. Therefore there is no validation group inside the buttons. To fix this problem I had to use the StepNavigationTemplate to assign the validation group inside the buttons. What the StepNavigationTemplate does is that it lets you create your own buttons for next and previous using CommandName=MoveNext or MovePrev. Creating my own buttons for my wizard step allows me to add the validation group inside the element.
  <asp:Button ID=”btn_Previous” runat=”server” Text=”Previous” CommandName=”MovePrevious” />
  <asp:Button ID=”btn_Next” runat=”server” Text=”Next” CommandName=”MoveNext” ValidationGroup=”info_form”  CausesValidation=”true” />