views:

28

answers:

2

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.

+1  A: 

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

tpeczek
@tpeczek - Good posts and I feel like they would solve my problem. However, I tried both your solution, as well as the on by Adam Craven, and it doesn't appear to be working. If it makes any difference, the AJAX forms are within jQuery UI Tabs and not in a "normal" AJAX form. (AKA Ajax.BeginForm()) Would that make a difference?
JasCav
@JasCav - To be honest I would have to test such a case, I'll try to do it. Can you send some of your source code so I can recreate your case exactly?
tpeczek
@tpeczek - Unfortunately, I wouldn't be able to send this code specifically (proprietary info and all that), but I can try to mock something up that demonstrate the problem. I have your email address from your blog. (BTW, +1 just for offering to help. Really appreciate that.)
JasCav
A: 

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.

JasCav