Click here to Skip to main content
15,887,083 members
Articles / Web Development / CSS

Customize Validation Summary

Rate me:
Please Sign up or sign in to vote.
4.86/5 (38 votes)
30 Sep 2010CPOL1 min read 144.7K   4.1K   56   37
The ASP.NET Validation Summary control with customized CSS and Style to display a summary of all validation errors that occur in a web page.
ValidationSummaryScreen.png

Introduction

The ASP.NET Validation Summary control with Stylish and Customized CSS to display a summary of all validation errors occurred in a web page.

Background

The error message displayed in this control is specified by the ErrorMessage property of each validation control. If the ErrorMessage property of the validation control is not set, no error message is displayed for that validation control.

Using the Code

The customized error message displayed in this control is specified by the following property of Controls and Validation Summary:

  1. Validation Control
    1. Text: (The icon to display when validation fails)
    2. ErrorMessage: (The text to display in the ValidationSummary control when validation fails. Note: This text will also be displayed in the validation control if the Text property is not set)
  2. Validation Summary
    1. DisplayMode: (Display the validation summary with BulletList)
    2. CssClass: (The CssClass property is used to set style or class to the ValidationSummary control. Validationsummary)
    3. HeaderText: (Display a header “Please correct the following:” in the ValidationSummary control)

HTML Structure

VS-Page.png

CSS Style

VS-CSS.png

Points of Interest

This was done using only CSS tricks.

If you find some issues, bugs with it, just leave a comment or drop me an email. If you make any notes to this, let me know that too so I don't have to redo any of your hard work.

Please provide a "Vote" if this would be helpful.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen


AWARDS:

  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010


Read More Articles...

Comments and Discussions

 
GeneralMy vote of 5 Pin
nrutter17-Feb-11 3:08
nrutter17-Feb-11 3:08 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen11-Apr-11 0:22
professionalSunasara Imdadhusen11-Apr-11 0:22 
GeneralMy vote of 5 Pin
hance_micle1-Dec-10 0:10
hance_micle1-Dec-10 0:10 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen3-Feb-11 18:23
professionalSunasara Imdadhusen3-Feb-11 18:23 
GeneralMy vote of 4 Pin
Member 24609926-Oct-10 1:25
Member 24609926-Oct-10 1:25 
GeneralRe: My vote of 4 Pin
Sunasara Imdadhusen2-Dec-10 22:14
professionalSunasara Imdadhusen2-Dec-10 22:14 
GeneralRe: My vote of 4 Pin
Sunasara Imdadhusen22-Apr-14 2:44
professionalSunasara Imdadhusen22-Apr-14 2:44 
GeneralSuggestion PinPopular
Richard Deeming5-Oct-10 7:29
mveRichard Deeming5-Oct-10 7:29 
Since the built-in validator controls are derived from the Label control, you can specify the Text as the content of the control. This will let you use server controls and app-relative paths to replace the page-relative image path.

For example, instead of:
<asp:RequiredFieldValidator ... 
	Text="<img src='../../App_Themes/Lims/Images/Exclamation.gif' title='Field is required' />" 
	...
></asp:RequiredFieldValidator>


you can use:
<asp:RequiredFieldValidator ...><asp:Image runat="server"
    ImageUrl="~/App_Themes/Lims/Images/Exclamation.gif"
    ToolTip="Field is required"
/></asp:RequiredFieldValidator>


This would also allow you to use control skins defined in your theme:

~/Folder/SomePage.aspx:
<asp:RequiredFieldValidator ...><asp:Image runat="server" SkinID="ValidationError"
    ToolTip="Field is required"
/></asp:RequiredFieldValidator>


~/App_Themes/Lims/Validators.skin:
<asp:Image runat="server" SkinID="ValidationError"
    ImageUrl="Images/Exclamation.gif"
/>

(Note the image URL in the skin file is relative to the theme directory - no need to hard-code your theme name in the URL.)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Suggestion Pin
Sunasara Imdadhusen5-Oct-10 23:25
professionalSunasara Imdadhusen5-Oct-10 23:25 
Generaldownloading the zip file Pin
Tilewa30-Sep-10 0:06
Tilewa30-Sep-10 0:06 
GeneralRe: downloading the zip file Pin
Sunasara Imdadhusen30-Sep-10 0:53
professionalSunasara Imdadhusen30-Sep-10 0:53 
GeneralRe: downloading the zip file Pin
Sunasara Imdadhusen30-Sep-10 1:08
professionalSunasara Imdadhusen30-Sep-10 1:08 
GeneralRe: downloading the zip file Pin
Tilewa30-Sep-10 1:10
Tilewa30-Sep-10 1:10 
GeneralRe: downloading the zip file Pin
Sunasara Imdadhusen30-Sep-10 1:15
professionalSunasara Imdadhusen30-Sep-10 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.