1

If you use a CustomValidator control and a ValidationSummary control within an aspx page for server side validation you can set the ErrorMessage of the validator and its Text value will appear in place and the ErrorMessage value will be displayed within the ValidationSummary control.

Nice.

Now, what if I also perform validation on the client side in javascript, is it possible to perform the same kind of validation message display as if the server side code had fired? So that the ValidationSummary would display its usual HeaderText along with your additional ErrorMessage and the CustomValidator would display its Text value (e.g. *)

I can probably fake it for client side vs. server side but it would be nice to use the existing controls if at all possible.

Thanks in advance for any ideas or suggestions

4

2 回答 2

2

You can make the validator itself run on the client side when you set EnableClientScript to be true. ClientValidationFunction can then be set to the name of the javascript function that you write to validate the control. The rest of the CustomValidator control's behavior will tie in with the ValidationSummary just like any other validator, including putting the ErrorMessage up in the header, etc. etc.

于 2009-08-25T21:42:24.717 回答
0

I have tried getting at the DOM object for the Summary during runtime, but unless you have a very simple page, i.r. no AJAX controls like panel etc, you are out of luck.

于 2009-08-25T21:18:08.900 回答