MVC3 Unobtrusive Validation Not Working after Ajax Call

后端 未结 5 727
既然无缘
既然无缘 2020-12-04 08:03

Ok, here is the deal, I have seen a few posts on SO relating to this issue, but nothing is working for me.

Basically, I have select drop downs that are being load

5条回答
  •  猫巷女王i
    2020-12-04 08:37

    I'm adding my experience as the above recommendations did not work for me. This solution did and may help others that get directed to this page from a search engine:

    Add OnSuccess="$.validator.unobtrusive.parse('YourFormName');" to you AjaxOptions

    An example using Ajax.ActionLink:

    @Ajax.ActionLink("This is a test to get unobtrusive javascript working",
                     "Name_of_your_controller_action",
                     new AjaxOptions { HttpMethod = "POST", 
                                       InsertionMode = InsertionMode.Replace, 
                                       UpdateTargetId = "UserDiv", 
                                       OnSuccess="$.validator.unobtrusive.parse('UserDetailsForm');"  
                                     }
                    )
    

    This solution was found at: http://blog.janjonas.net/2011-07-24/asp_net-mvc_3-ajax-form-jquery-validate-supporting-unobtrusive-client-side-validation-and-server-side-validation

提交回复
热议问题