Click here to Skip to main content
12,826,465 members (25,662 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 3 Aug 2004

Taming ASP.NET Validation Summary control

, 3 Aug 2004
Rate this:
Please Sign up or sign in to vote.
To disable and enable Validation Summary control in ASP.NET while displaying customized error messages to avoid displaying duplicate error messages.


ASP.NET provides lot of very strong and effective web controls. One of the most widely used controls is Validation Summary control. It gives us a neat and clean way to display error messages on the web page.

With my current program assignment I came across a problem when I had to disable the Validation Summary control on one button click and enable Validation Summary control on the same or other button click.

I know some of you might say OH what a big deal just use enable or visible property and we can accomplish the task. Yes you can but if you are not getting the desired result that you wanted, please read further.


One of the basic problems, I came across was disabling the page validation summary control while displaying customized error messages. I was running into issue with duplicate error messages being displayed on the screen.

And finally I was able to find a solution for it and would like to share the solution with you hard working programmers- maybe this solution will save you some pain of taming Validation Summary control of ASP.NET

This example requires just very basic knowledge of java script so don’t be scared I promise this will be one of the easiest java scripts that can solve a complex problem.

Add the following text to the page tag on top of your aspx page:


The modified page tag will look something like this:

<%@ Page Language="vb" AutoEventWireup="false" 
  Codebehind="Mypage.aspx.vb" Inherits="MyPage" 
  clienttarget="downlevel" %>

Then add the following java script to your page:

<script language="JavaScript"> 
document.all["buttonName"].onclick = 
  new function("Page_ValidationActive=true;"); 

Then add the following code to the button click event:

 If Page.IsValid Then
   Lblerror.text = “your custom error message”
 If Validationsummary1.Visible = True Then
   Validationsummary1.Visible = False
 End If
     If Validationsummary1.Visible = False Then
            Validationsummary1.Visible = True
            lblError.Text = ""
     End If
 End If        
  • ValidationSummary1 is the validation summary control on the page.
  • lblError is the label control to display your custom error messages.

In addition to this, if you want to disable the page validation on the cancel event of some secured page [to go back to previous page] that is a page with https, you might want add the following java script to your aspx page

<script language="JavaScript"> 
document.all["CancelbuttonName"].onclick = 
  new function("Page_ValidationActive=false;"); 


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Manu Gupta (
Web Developer
United States United States
Involved in architecture, designing, programming and program management of advanced technologies such as Single Sign On SAML, Federated identity solutions and various projects in ASP.NET with SQL server 2000

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 4 Aug 2004
Article Copyright 2004 by Manu Gupta (
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid