开发者

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. 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 pro开发者_开发问答cess would be much appreciated. Thank you.


Check out those links, they should get you on right track:

  • http://tpeczek.com/2010/04/unobtrusive-asynchronous-form-in-aspnet.html
  • http://tpeczek.com/2010/04/making-aspnet-mvc-2-client-side.html


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.

As a result, the client-side validation now works without any additional hacks per Scott Guthrie's article.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜