简体   繁体   中英

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 process would be much appreciated. Thank you.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM