Validation Summary Control in ASP.NET


To summarize the validation errors on a web page we use Validation Summary Control in ASP.NET. However, for a basic understanding of server-side validation controls, you can read this article.

Important Points Regarding the validation Summary Control

  • In fact, this control doesn’t perform any validation itself but only collects error information from other validation controls and displays it in a specified format.
  • Instead of using it as a stand-alone control, the ValidationSummary control is used along with other validation controls.
  • Furthermore, This control displays the consolidated error messages on a web page.
  • Since you get complete error information in one place, there is no need to look at error messages produced by individual validation controls.
  • For the purpose of displaying error information, the ValidationSummary control uses the ErrorMessage property of individual validation controls.

Example of Validation Summary Control

As an illustration, we use the ValidationSummary control along with three more validation controls that we have used in the previous example. Although, it is one of the simplest and easy to use control in ASP.NET, evidently its use on a web page makes the page attractive and user-friendly.

Specifically, the example uses two more properties along with the styling properties. Firstly, the HeaderText property specifies the text that is displayed on the top. Similarly, the DisplayMode property specifies the format in which the summary should be displayed. For example, the value “BulletedList” shows error messages in a bulleted list. While other possible values of the DisplayMode property are List and SingleParagraph.

Another key point is that you can also show the error summary using a Message Box. For this purpose, it has a property called ShowMessageBox that you can set to true.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ValidationControlExamples.WebForm1" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
           Enter Some Text:  *<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
            <asp:RequiredFieldValidator ID="r1" runat="server" 
                ErrorMessage="The Field Can't be Left Blank"
                 Text="This Field is Mandatory!"

            <hr />
            Comparing the Content of Two Fields<br />
            Enter Text: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
            Enter Text Again: <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
            <asp:CompareValidator ID="c1" runat="server" 
            ErrorMessage="Two Values don't match"
             <hr />

            Validating Range
            Enter a number [10-100]: <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br />
            <asp:RangeValidator ID="r2" runat="server" 
            ErrorMessage="Invalid Range!"
             Text="Value Not in Given Range!"
                              runat="server" />
                              HeaderText="Errors on the page!"
            <hr />


Validation Summary Control in ASP.NET
Validation Summary Control in ASP.NET


To sum up, the ValidationSummary controls is one of the important control available in ASP.NET. Also, it increases the readability of the web page considerably. Unlike other validation controls, we don’t use it stand-alone but along with other validation controls. Hence, it consolidates error information from other controls and displays it in a specific part of the web page.

Further Reading

Parameter and ParameterCollection in ADO.NET

Database Manipulation Using DataGrid

Example of Button and Link Button Control in ASP.NET

Example of Chart Control in ASP.NET

Creating a DataTable from a DataReader in ASP.NET

Deleting a Record using DataGrid Control in ASP.NET

Edit a Record Using DataGrid Control in ASP.NET

Insert a Record Using ItemCommand Event in DataGrid

CRUD Operations with DataGrid in ASP.NET

Creating Columns in a DataGrid Control

XML Documents and DataSet in ASP.NET

Code Render Block in ASP.NET

ASP.NET Core Features and Advantages

Display Images Using DataList Control

Adding Images Using Image Control

Creating a Group of Radio Buttons Using RadioButtonList Control

Example of Button Control in ASP.NET

Using MD5 Hash Algorithm

ItemDataBound Event in DataList

More Features of DataList in ASP.NET

A Simple Example of Using a DataList Control in ASP.NET

Properties and Methods of DataList Control in ASP.NET

ASP.NET Practice Exercise

Exploring DataList Control in ASP.NET

Custom Validator Control in ASP.NET

Validation Summary Control in ASP.NET

Validation Controls Examples – RequiredFieldValidator, CompareValidator, and RangeValidator

An Example of Data Binding with RadioButtonList Control

Binding Data to Web Control in ADO.NET

Examples of AdRotator Control in ASP.NET

Examples of Validation Controls in ASP.NET

Overview of MVC architecture in ASP.NET


You may also like...