Thursday, March 29, 2012

Manually Reset Validation Status

Once I manually call the Validation routine via Page_ClientValidate(); which displays the validation summary great, how can I manually turn it off if I want, even if the page is currently not valid?
I tried setting the boolean for Page_ValidationActive to false but it didn't make the validation text disappear again. Do I need to call some other function after setting the boolean to false like Page_ClientDontValidate() =)
Page_ValidationActiveBoolean variableIndicates whether validation should take place. Set this variable to False to turn off validation programmatically.
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp
hello.
i think that you're talking about the summary shown by the validationsummary control, right?
if you want to hide them, then you can use the jscript array Page_ValidationSummaries to get a reference to all the valiadtion summaries that exist in a page and then you can set it's display to none. here's an example of how to hide all the summaries:
for( var i = 0; i < Page_ValidationSummaries.length; i++ )
{
Page_ValidationSummariesIdea [I].style.display = "none";
}
Thank you for writing, that worked a little too good. =) When I try to get the validators to fire again, they won't show up. I guess I'm looking for a way to "reset" the page back to the way it was on page load, but still allow the validators to work as normal on the next change to the text that would fire the validators again.
The only way I can think of is to combine your function above, with another function that gets called onchange for each field and does the same thing but the opposite value, Page_ValidationSummariesIdea [I].style.display=Page_IsValid? block : none;
Seems like a lot processing to reset the state.
The reason I'm doing this is I use drop down list onchange with ajax that refreshes the data on the page and Page_Load doesn't get called after the Initial Load of the page.
John

0 comments:

Post a Comment