Add your own error message to a ValidationSummary

There are time where you need to display a message to the users.  Here’s how to do it with a Validation Summary on your ASP.NET page.
I use this when I want to display an error message that doesn’t come from an exception or another validation.
This is helpful when you want all messages to have the same look and feel.

Below is the code.

CustomValidator val = new CustomValidator();
val.IsValid = false;
val.ErrorMessage = "My error message for the ValidationSummary";

You create create a custom validator, set it to invalid, define the error message, and add it to your page.

posted @ Tuesday, August 6, 2013 5:11 PM


Comments on this entry:

No comments posted yet.

Your comment:

 (will not be displayed)

Please add 4 and 6 and type the answer here:

Live Comment Preview: