Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From <a href="http://forums.asp.net/p/1022184/1385194.aspx" rel="nofollow noreferrer">http://forums.asp.net/p/1022184/1385194.aspx</a></p> <p>After searching over and over on how to validate my wizard control steps, i came up with these solutions. Remember that each step should have it's own validation group. For these sample i use "Form" as my validation group.</p> <p>1) Validation on the next button click. For this one, i simply override the Previous and Next button autogenerated by the Wizard Control by using 2 asp:Button. You then set the cause validation to true and you assign a validation group. Note that the important part is in the CommandName section.</p> <pre><code>&lt;StepNavigationTemplate &gt; &lt;asp:Button ID="btnPrevious" runat="server" CssClass="WizardControlButton" Text="Previous" CommandName="MovePrevious" /&gt; &lt;asp:Button ID="btnNext" runat="server" CssClass="WizardControlButton" CommandName="MoveNext" Text="Next" CausesValidation="true" ValidationGroup="Form" /&gt; &lt;/StepNavigationTemplate&gt; </code></pre> <p>2) Validation on Sidebar click This one is also simple. You add the code in the SideBarButtonClick event of your control and then you check the step id you are currently. After it validates the page with the validation group in parameters. If the page is not valid. It cancel the event. </p> <pre><code>Protected Sub wizRegistration_SideBarButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wizRegistration.SideBarButtonClick If wizRegistration.ActiveStep.ID = "wizSelectPostalCode" AndAlso e.NextStepIndex &gt; e.CurrentStepIndex Then Page.Validate("Form") If Not Page.IsValid() Then e.Cancel = True End If End If End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload