开发者

Page with multiple validation groups always returns TRUE for Page.IsValid

开发者 https://www.devze.com 2022-12-13 00:54 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号