复杂模型验证

发布于 2024-11-18 19:26:48 字数 189 浏览 8 评论 0原文

有没有办法使用复杂的规则来实现模型验证,例如“如果选择了一个单选按钮,则需要从另一个单选按钮组中选择一个单选按钮。如果选择了带有附加文本框的单选按钮,则也需要填充它。”? 如果这种方式能与 DataAnnotations 属性相关就完美了。我只知道我们可以使用一些额外的框架来实现这一目标。但是,你知道,如果我们有一些本地解决方案,那就更漂亮了。 提前谢谢你们了!

Is there ways to implement model validation with complex rules like "if one radio button was selected it's necessary to select one radio from another radio buttons group. If radio button with additional textbox was selected so it's necessary to fill it too."?
It'll be perfect if this way will relate to DataAnnotations attributes. I only know that we can use some additional framework to reach this. But, you know, it'll be more beautiful if we have some native solution.
Thanks you guys in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巨坚强 2024-11-25 19:26:48

我不认为 MVC-2 有原生解决方案,但我相信 MVC-3 支持使用 RemoteAttribute 进行远程验证的概念。我认为更多信息可以找到:

MVC 3 发行说明概述

RemoteAttribute

I don't think MVC-2 has a native solution but I believe MVC-3 supports the concept of remote validation using a RemoteAttribute. I think more information can be found:

MVC 3 Release notes overview

RemoteAttribute

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文