ASP.Net MVC:您可以使用数据注解/验证与AJAX / jQuery的电话吗? [英] ASP.Net MVC: Can you use Data Annotations / Validation with an AJAX / jQuery call?

查看:241
本文介绍了ASP.Net MVC:您可以使用数据注解/验证与AJAX / jQuery的电话吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用数据注释/验证与AJAX / jQuery的电话吗?如果有,请提供一个例子或帖子里面给出了一个例子。

Can you use Data Annotations / Validation with an AJAX / jQuery call? If so, please provide an example or a post which shows an example.

基本上,我已经看到了如何使用数据注释的一个例子,但它是一个完整的回发。有没有办法做一个AJAX / jQuery的电话吗?不知道你将如何做到这一点,因为我不知道你将如何构建模型对象的客户端。 (我想这是你必须做的事。)

Basically I have seen an example of how to use Data Annotations, however it was with a full post back. Is there a way to do with an AJAX / jQuery call? Not sure how you would do this since I am not sure how you would construct the Model object on the client side. (I assume this is what you would have to do.)

有人告诉我,这是可以做到的,但我就是不明白,怎么会这样。

Someone told me this can be done, but I just don't understand how it can be.

感谢您的帮助。

推荐答案

如果你使用(而不是Html.BeginForm)Html.AjaxForm然后将验证使用Ajax。

If you use Html.AjaxForm (instead of Html.BeginForm) then it will validate using Ajax.

不过,我不认为你可以验证使用jQuery。微软有它自己的Ajax库和他们称之为/维护它自己。我不认为你可以连接自己的code之间。

However I don't think you can validate using jQuery. Microsoft has it's own Ajax libraries and they call/maintain it themselves. I don't think you can hook your own code in between.

这篇关于ASP.Net MVC:您可以使用数据注解/验证与AJAX / jQuery的电话吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆