0

I am using partial views and ajax based functionality to POST to my controller. I want to know how I can leverage the validation functionality I normally get with the MVC Razor forms and using a full page post back with a async based framework.

Pseudo Code

     function buttonpress()
     {
           if(Validate())
              .... Call server functionality with AJAX and handle result
           else
              .... Show standard validation messages as normal. Do not contact server
     }
     function Validate()
     {
           ... Check the validation like it would with full post back
           ... Should also limit to a group too
     }

I don't want to rewrite the all the free validation I get from the framework if I don't have to.

DanScan
  • 831
  • 2
  • 10
  • 23
  • Have a look at the Ajax Form. Good example here http://stackoverflow.com/questions/5410055/using-ajax-beginform-with-asp-net-mvc-3-razor – asymptoticFault Sep 16 '13 at 18:12
  • I had a view in an iframe where the validation was working as you mention. Researching everyone was saying iframes aren't ideal so I rewrote the page as a partial view opening with a overlay but I lost all of the validation. I don't know if you have found a solution for this but you might try a full frame in an iframe – Matt Bodily Sep 25 '13 at 02:22
  • Esentially I scrapped the Built in Validation and went with Knockoutjs for my user interface. I do have to "rewrite" some stuff but it is easy to do and gives me some extra stuff like extenders. Checkout: http://stackoverflow.com/questions/18965738/knockoutjs-validation-for-aresame-or-mustmatch-examples and http://stackoverflow.com/questions/18969081/stop-knockoutjs-validation-during-applybindings-init-onload – DanScan Sep 26 '13 at 19:20

0 Answers0