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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ASP.net MVC form post with jQuery & validation

  • 20-07-2010 10:23pm
    #1
    Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭


    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, Registered Users 2 Posts: 2,793 ✭✭✭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