DataAnnotation JQuery 无缝集成?

发布于 2024-10-08 19:17:23 字数 531 浏览 0 评论 0原文

好像我过去见过这是如何完成的,但现在似乎找不到了。

Scott Gu 的 在 MVC V2 预览帖子中,他表示他们正在发布 JQuery 验证插件,很快您就可以使用 DataAnnotations 来装饰您的 ViewModel,并有一个地方来指定客户端和服务器验证。

在未来的 ASP.NET MVC 2 预览中,我们计划发布 jQuery 验证插件作为 默认项目模板,并添加 支持自动客户端 JavaScript 执行 DataAnnotation验证规则为 出色地。这将使开发人员能够 轻松添加验证规则 放置在模型或视图模型上 反对,并强制执行 客户端和服务器端无处不在 在应用程序内使用。

我不知道这是如何完成的或者是否曾经实施过。有人可以启发我吗?

Seems like I have seen how this is done in the past, but I can't seem to find it now.

In Scott Gu's MVC V2 preview post he states they are shipping the JQuery validation plugin and soon you can use DataAnnotations to decorate your ViewModels and have a single place to specify client and server validation.

In a future ASP.NET MVC 2 preview we are planning to ship the jQuery
Validation plugin as part of the
default project template, and add
support for the automatic client-side
JavaScript enforcement of
DataAnnotation validation rules as
well. This will enable developers to
easily add validation rules in one
place on either a Model or ViewModel
object, and have them be enforced both
client and server-side everywhere it
is used within the application.

I can't find how this is done or if it was ever implemented. Can someone enlighten me please?

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

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

发布评论

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

评论(1

纸短情长 2024-10-15 19:17:23

如果您好奇这是如何实现的,您可以查看 Steve Sanderson 的 xVal 框架。

http://xval.codeplex.com/

正如该页面所述,xVal 不再被积极开发,并且仅适用于 MVC v1,因为 MVC v2 中实现了类似的功能。 Scott Guthrie 在这篇文章中讨论了该功能:

http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

它存在于 ASP.NET 中MVC v2 和 v3。如果您想了解它在 ASP.NET MVC v2 中是如何实现的,可以从这里下载源代码:

http://aspnet.codeplex.com/releases/view/41742

If you're curious how this is implemented, you can check out Steve Sanderson's xVal framework.

http://xval.codeplex.com/

As noted on that page, xVal is no longer being actively developed and only intended for MVC v1 as a similar feature is implemented in MVC v2. Scott Guthrie talks about the feature in this post:

http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

and it is present in ASP.NET MVC v2 and v3. If you want to know how it is implemented in ASP.NET MVC v2, you can download the source code from here:

http://aspnet.codeplex.com/releases/view/41742

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