Is there a method I can call that retrieves a boolean value of whether or not a particular ValidationGroup is valid? I don't want to actually display the validation message or summary - I just want to know whether it is valid or not.
Something like:
Page.IsValid("MyValidationGroup")
Validate method is fired automatically by controls that have the CausesValidation property set to true(Which is default value for Button control). Page. IsValid property tells you whether the validation succeeded or not.
If you use the Page. Validate() method on an ASP.NET 2.0 page, validation groups are ignored and all controls are validated.
Validation groups allow you to organize validation controls on a page as a set. Each validation group can perform validation independently from other validation groups on the page. You create a validation group by setting the ValidationGroup property to the same name (a string) for all the controls you want to group.
Have you tried using the Page.Validate(string) method? Based on the documentation, it looks like it may be what you want.
Page.Validate("MyValidationGroup"); if (Page.IsValid) { // your code here. }
Note that the validators on the control that also caused the postback will also fire. Snip from the MSDN article...
The Validate method validates the specified validation group. After calling the Validate method on a validation group, the IsValid method will return true only if both the specified validation group and the validation group of the control that caused the page to be posted to the server are valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With