Glossary Item Box

AspLib component library Send comments on this topic.

Validation groups

Validation groups

You can assign a group name to a set of validators to ensure that validation occurs only for controls in the specified group. This enables you to have multiple separately validated forms on a single page.

By default, page validation is not performed when a tab is selected. Page validation determines whether the input controls associated with a validation control on the page all pass the validation rules specified by the validation control. You can specify or determine whether validation is performed on both the client and the server when a tab is clicked by using the CausesValidation property. To prevent validation from being performed, set the CausesValidation property to false. Set the group name ValidationGroup on validator controls and on the tab that causes validation. By default, all validators are in the "" group (default group), for backward compatibility.

TabStrip and TabStripPage has properties CausesValidation and ValidationGroup.

If user uses TabStrip's properties then TabStripPage's properties are ignored.

If TabStrip.CausesValidation = true then user will be unable to switch tabs until validator isn't valid.
If user will use TabStripPage's properties then he will be able to switch to PREVIOUS tab and unable to switch to NEXT tab until validator isn't valid - this behavior useful for wizard-like interfaces.

 

Here's the sample code:

<al:TabStrip ID="TabStrip1" runat="server" EnableAjaxBehavior="False">
<Pages>
    <al:TabStripPage runat="server" Text="About Product">
        <
strong>Product Description</strong>
    </al:TabStripPage>
    <al:TabStripPage CausesValidation="true" runat="server" Text="Order">
        <span>Quantity:</span>
        <asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtQuantity" ErrorMessage="*"></asp:RequiredFieldValidator>
        <asp:Button ID="btnSubmit" runat="server" Text="Order" OnClick="btnSubmit_Click" />
    </al:TabStripPage>
    <al:TabStripPage runat="server" Text="Submit">
        <span>Quantity:</span>
        <asp:Label ID="litQuantity" runat="server" Font-Bold="True"></asp:Label>
    </al:TabStripPage>
</Pages>
</
al:TabStrip>

 

 

 

 


© 2002-2007 Astron Digital. All Rights Reserved.