Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP.net MVC form post with jQuery & validation

Options
  • 20-07-2010 11:23pm
    #1
    Registered Users Posts: 2,791 ✭✭✭


    Hi,

    I'm having problems using jQuery to make a form post to my controller whilst still keeping the MVC Data Annotations validations working.

    If I hook up the jQuery event then the post is made even if the client validation has failed.

    Ideally, I'd like to be able to make the post using jQuery, and replace the content of another div with the result. Has anyone been able to do this in combination with the MVC validators?

    I'm trying to get around this by using the form post action but I'm having problems replacing the other div when the form action has been successful.

    Any help would be appreciated!
    John


Comments

  • Registered Users Posts: 2,791 ✭✭✭John_Mc


    I got this working by using the ASP.net ajax form instead of a regular form. This is exactly what I was looking for..
    <% using (Ajax.BeginForm("Post", new AjaxOptions
               {
                   UpdateTargetId = "GBPostList",
                   InsertionMode = InsertionMode.InsertBefore,
                   OnSuccess = "getGbPostSuccess",
                   OnFailure = "showFaliure"
               }))
    
    


Advertisement