Validationsummary

G

Guest

Is there a way to reference the value of a validationsummary control? I have
a need to display any validation errors on my pages in a unique way and the
normal output of the validationsummary control does not meet that
requirement. However if I were able to capture the output that the
validationsummry writes to the screen, into a string variable that would most
likely solve my problem. Any one have any ideas?
 
B

bruce barker

sure, create your own validation summary that inherits from the default one,
and change the error display. if you change it very much, you will need to
update webuivalidation.js to support your output.

-- bruce (sqlwork.com)


| Is there a way to reference the value of a validationsummary control? I
have
| a need to display any validation errors on my pages in a unique way and
the
| normal output of the validationsummary control does not meet that
| requirement. However if I were able to capture the output that the
| validationsummry writes to the screen, into a string variable that would
most
| likely solve my problem. Any one have any ideas?
 
J

John M Deal

One way to do this is to loop through the validators collection of the
page and retrieve the error messages directly. Here's a bit of code
that does this:

foreach (Control currentControl in this.Page.Validators)
{
IValidator currentValidator = currentControl as IValidator;
if (currentValidator != null)
{
if (!currentValidator.IsValid)
{
Label currentValidationMessage = new Label();
currentValidationMessage.Text = currentValidator.ErrorMessage;
//Do something with the label here
}
}
}

I snipped this out of a custom validation summary control that I
developed for the same reason that you specified. Hope it helps.

Have A Better One!

John M Deal, MCP
Necessity Software
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top