I have two validation groups and two validation summaries on my page. Controls belong to either of two groups and there is a button for each group that performs the validation for each.
I can't get Page.IsValid开发者_开发技巧
to work; it always returns true regardless of the validity of the controls on the page. Is there a different way to validate only particular groups?
Try performing Page.Validate
before you check Page.IsValid
like:
this.Page.Validate("ValidationGroup");
if (this.Page.IsValid)
{
...
}
Where "ValidationGroup"
is the name of your validation group. If you use the Page.Validate()
method without a group name parameter the validation groups are ignored and all controls are validated.
精彩评论