Validationsummary

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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?
 
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
 
Back
Top