[英]Enabling Client-Side Validation in ASP.NET MVC 2 and AJAX
Scott Gu wrote an excellent article explaining how to apply the Data Annotation validation in ASP.NET MVC 2. I have implemented the items in this article for the server-side work, and it works well. Scott Gu 撰写了一篇出色的文章,解释了如何在ASP.NET MVC 2中应用数据注释验证。我已经在服务器端工作中实现了本文中的内容,并且效果很好。 I get back error messages when there is a problem.
出现问题时,我会返回错误消息。
I tried to add the code to also hook in client-side error messages (so a message is displayed when I tab out of a field that violates the rules), but, unfortunately, this does not appear work. 我试图添加代码以同时挂接客户端错误消息(因此当我从违反规则的字段中跳出时会显示一条消息),但是不幸的是,这似乎没有用。 I want to provide more information for my question, but I'm not even sure where to debug where my problem is at the moment.
我想为我的问题提供更多的信息,但是我什至不确定目前在哪里调试我的问题。 How can I do that?
我怎样才能做到这一点?
To describe my site layout: 要描述我的网站布局:
Site.Master - The Html.EnableClientValidation() call is here.
Index.aspx - Contains code to turn partial pages into a tab via jQuery UI tabs.
PartialPage1.ascx - Contains the fields that I want validated.
PartialPage2.ascx - Contains the fields that I want validated.
Any help or suggestions on where/how to start the debugging process would be much appreciated. 在任何地方/如何开始调试过程的任何帮助或建议,将不胜感激。 Thank you.
谢谢。
Check out those links, they should get you on right track: 查看这些链接,它们将使您步入正轨:
I ended up changing how my entire web application works (one problem is that I did not have a full grasp on ASP.NET MVC), so I have since switched over to utilizing that more correctly and I am now not relying on (misused) AJAX. 我最终改变了整个Web应用程序的工作方式(一个问题是我对ASP.NET MVC并不完全了解),所以从那以后我转向更正确地利用它,而现在我不再依赖(滥用)了。 AJAX。
As a result, the client-side validation now works without any additional hacks per Scott Guthrie's article. 因此,根据Scott Guthrie的文章,现在可以进行客户端验证,而无需任何其他黑客。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.