File: Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ValidationGroups" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Panel Height="112px" ID="Panel1" runat="server" Width="392px"> <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="Group1"></asp:TextBox> <asp:RequiredFieldValidator ErrorMessage="*Required" ID="RequiredFieldValidator1" runat="server" ValidationGroup="Group1" ControlToValidate="TextBox1"></asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Validate Group1" ValidationGroup="Group1" OnClick="Button_Click"/></asp:Panel> <br /> <asp:Panel Height="94px" ID="Panel2" runat="server" Width="392px" BorderWidth="2px"> <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="Group2"></asp:TextBox> <asp:RequiredFieldValidator ErrorMessage="*Required" ID="RequiredFieldValidator2" runat="server" ValidationGroup="Group2" ControlToValidate="TextBox2"> </asp:RequiredFieldValidator><br /> <br /> <asp:Button ID="Button2" runat="server" Text="Validate Group2" ValidationGroup="Group2" OnClick="Button_Click"/></asp:Panel> <asp:Label EnableViewState="False" ID="lblInfo" runat="server"></asp:Label><br /> </div> </form> </body> </html> File: Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ValidationGroups : System.Web.UI.Page { protected void Button_Click(object sender, EventArgs e) { if (Page.IsValid) { lblInfo.Text = "Page posted back at " + DateTime.Now.ToLongTimeString(); } } }