articles

Home / DeveloperSection / Articles / ValidationSummary Control in ASP.Net

ValidationSummary Control in ASP.Net

Pushpendra Singh 7917 11-Nov-2010

The ValidationSummary control is used to display a summary of all validation errors occurred in a Web page.

<asp:ValidationSummary ID="ValidationSummary1" runat="server" />

ValidationSummary Control in ASP.Net

Properties

Display Mode

How to display the summary. Legal values are:

·         BulletList

·         List

·         Single Paragraph

ShowMessageBox

A Boolean value that specifies whether the summary should be displayed in a message box or not

Show Summary

A Boolean value that specifies whether the ValidationSummary control should be displayed or hidden

Code:

<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
    <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
        ErrorMessage="Enter Your Name">*</asp:RequiredFieldValidator>
    <br />
    <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label3" runat="server" Text="Confirm Password"></asp:Label>
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox2"
        ControlToValidate="TextBox3" ErrorMessage="NOT MATCHED">*</asp:CompareValidator>
    <br />
    <asp:Label ID="Label4" runat="server" Text="Email Id"></asp:Label>
    <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox4"
        ErrorMessage="enter a valid email id" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Submit" />

 

ValidationSummary Control in ASP.Net

ValidationSummary Control in ASP.Net


Updated 04-Mar-2020

Leave Comment

Comments

Liked By