Two validation groups : ValidationGroup « Validation « ASP.NET Tutorial






<%@ page language="C#" %>

<script runat="server">

</script>

<html>
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form runat="server">
        <h1>First form</h1>
        
            <asp:textbox id="TextBox1" runat="server" validationgroup="firstform">
            </asp:textbox>
            <asp:requiredfieldvalidator 
                 id="RequiredFieldValidator1" 
                 runat="server" 
                 display="Dynamic"
                 setfocusonerror="True" 
                 validationgroup="firstform" 
                 controltovalidate="TextBox1">***</asp:requiredfieldvalidator>
            <br />
            <br />
            <asp:button id="Button1" runat="server" validationgroup="firstform" text="Submit" />
        


        <h1>Second form</h1>
        
            <asp:textbox id="TextBox2" runat="server" validationgroup="secondform">
            </asp:textbox>
            <asp:requiredfieldvalidator 
                id="RequiredFieldValidator2" 
                runat="server" 
                display="Dynamic"
                setfocusonerror="True" 
                validationgroup="secondform" 
                controltovalidate="TextBox2">***</asp:requiredfieldvalidator>
            <br />
            <br />
            <asp:button id="Button2" runat="server" validationgroup="secondform" text="Submit" />            
        

    </form>
</body>
</html>








8.12.ValidationGroup
8.12.1.A validation group enables you to group related form fields together.
8.12.2.Validation Groups Demo
8.12.3.Group based validation (C#)
8.12.4.Two validation groups
8.12.5.Using the ValidationGroup property (VB)