开发者

Can an ASP.NET Validation Rule belong to multiple groups?

开发者 https://www.devze.com 2022-12-21 00:49 出处:网络
Is it possible for an ASP.NET Validation Rule to belong to multiple groups? I\'d like to validate the same control in different ways based on what mode the form is in using a single Validator.

Is it possible for an ASP.NET Validation Rule to belong to multiple groups? I'd like to validate the same control in different ways based on what mode the form is in using a single Validator.

For the purposes of this question, the modes are Simple, which requires fewer fields, or Complex, which requires more field开发者_开发技巧s. I know I can write CustomValidators (which I have done in the past), but I'd like a simpler solution.

So, I'd like to combine the following:

<asp:RequiredFieldValidator ValidationGroup="Simple" ControlToValidate="Name" />
<asp:RequiredFieldValidator ValidationGroup="Complex" ControlToValidate="Name" />

Thanks!


No, unfortunately they cannot. But to my understanding your page is never shown in simple and complex mode at the same time, so maybe you should just add the validator from codebehind and set the validationgroup based on the current mode.


There is no support for multiple validation groups on a validator or button in the ASP.NET Validators

0

精彩评论

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