Use of Validation Group in asp.net


HTML:


<div>
<asp:TextBox ID="TextBox1" Runat="server" ValidationGroup="First"></asp:TextBox>

<asp:TextBox ID="TextBox2" Runat="server" ValidationGroup="First"></asp:TextBox><br />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" ValidationGroup="First"
ErrorMessage="TextBox1 should not be blank" ControlToValidate="TextBox1">

</asp:RequiredFieldValidator>
<asp:Button ID="Submit1" Runat="server" ValidationGroup="First" Text="Submit 1" />

<br />
<br />

<asp:TextBox ID="TextBox3" Runat="server" ValidationGroup="Second"></asp:TextBox>

<asp:TextBox ID="TextBox4" Runat="server" ValidationGroup="Second"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server" ErrorMessage=" TextBox3 should not be blank"
ControlToValidate="TextBox3" ValidationGroup="Second">
</asp:RequiredFieldValidator>

<asp:Button ID="Submit2" Runat="server" ValidationGroup="Second" Text="Submit 2" />
    
</div>


Use of Validation Group is shown above

Thanks
RajShree

Ebook Download
View all
Learn
View all