Here i have explained how to use ValidationSummary control in Asp.Net.

ValidationSummary control is used to show  error messages in a summary.

HTML Markup

<asp:textbox runat="server" id="txtAge"></asp:textbox>

<asp:requiredfieldvalidator id="RequiredFieldValidator2" errormessage="Please enter your age" display="None" controltovalidate="txtAge" runat="server">
</asp:requiredfieldvalidator>
<asp:comparevalidator ID="Comparevalidator1" errormessage="Age must be integer." display="None" type="Integer" operator="DataTypeCheck" controltovalidate="txtAge" runat="server"> </asp:comparevalidator>

<asp:textbox runat="server" id="txtEmail"></asp:textbox>

<asp:requiredfieldvalidator id="RequiredFieldValidator3" errormessage="Please enter your email" display="None" controltovalidate="txtEmail" runat="server"> 
</asp:requiredfieldvalidator>
<asp:regularexpressionvalidator ID="Regularexpressionvalidator1" errormessage="Invalid email format." display="None" controltovalidate="txtEmail" runat="server" validationexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"> </asp:regularexpressionvalidator>

<asp:button text="Submit" id="btnSave" runat="server" onclick="btnSave_Click"> </asp:button>

<asp:validationsummary forecolor="Red" runat="server" id="validationSummary"> </asp:validationsummary>

 <asp:Label ID="lblmsg" runat="server" ForeColor="Green"></asp:Label>

C#

protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            lblmsg.Text = "Thank you!";
        }
    }

Screenshot

Add Comments