ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash


 Top ASP 101 Stories Top ASP 101 Stories
VBScript Classes: Part 1 of N
Migrating to ASP.NET
Getting Scripts to Run on a Schedule

QUICK TIP:
Make Access Write Your SQL For You
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Taming the ASP.NET Validation Summary Control

by Manu Gupta

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

During 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 an issue where duplicate error messages were being displayed on the screen. After finally finding a solution to the problem, I would like to share my solution with you hard working programmers so that maybe this solution will save you some pain of taming Validation Summary control of ASP.NET.

The following also deals with a problem of going back functionality on secure pages with https. If you are getting the Warning page expired message when you click back button to go to previous screen, the use of following article can come handy.

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 and it can solve a complex problem.

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

clienttarget="downlevel"

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;");

</script>

Then add the following code to the button click event:

Page.Validate()

If Page.IsValid Then
	Lblerror.text = "your custom error message"
	If Validationsummary1.Visible = True Then
		Validationsummary1.Visible = False
	End If
Else
	If Validationsummary1.Visible = False Then
		Validationsummary1.Visible = True
		lblError.Text = ""
	End If
End If

Where ValidationSummary1 is the validation summary control on the page and 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;");

</script>

GOOD LUCK !!!

Manu Gupta
Senior Programmer Analyst
Progressive Consulting Technologies


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES