views:

42

answers:

2

i have a validationSummary in my page. i want to call a javascript function after the validationSummary is filled. how can i achieve this?

i think i should add an attribute in the code behind, but i can't figure out what is the attribute's key.

any help?

A: 

I don't think that's possible. It is, however, possible to intercept validation by setting OnClientClick on the controls that do postbacks. Then you can check the global JavaScript variable Page_IsValid for the validation result.

One thing to keep in mind is that, when there are no validators on a page, Page_IsValid will be undefined.

ErikHeemskerk
A: 

You will want to call the javascript function Page_ClientValidate() to initiate the ASP.NET validation wired to your page controls. Once this is called, the Page_IsValid boolean value will be properly set.

Here is an example of how I am using it. If ASP.NET validation is successful, I disable the button, otherwise the button remains enabled and the validation summary is displayed to the user. The OnClientClick is from a ASP:Button control.

OnClientClick="javascript:Page_ClientValidate(); if (Page_IsValid==true) { this.disabled=true; }"

EverettEvola