Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Validation And Update Panel Together

I m trying to use jquery validation plugin but my form is in update panel. So even after applying the validation on submit the form it validates and shows the required message for hardly 2 seconds and then submits the form.
What is the workaround for this?

I have tried this also.

<asp:UpdatePanel ID="AddUserPanel" runat="server"
             ChildrenAsTriggers="false"
             UpdateMode="Conditional">

But this also doesn't seem to help.

like image 451
Shrikant Avatar asked Sep 13 '10 10:09

Shrikant


1 Answers

If your using a script manager you need the l33t code below:

  $(function () {
 //Code that runs before update panel is fired.

        //Listen for update panel
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        //Re-initialize jquery after an auto post back.
        function EndRequestHandler(sender, args) {
            //Do work after update panel fires.
        } 
    });

So basically you have duplicate code, code outside of the EndRequestHandler() and inside it.

like image 143
The Muffin Man Avatar answered Oct 19 '22 23:10

The Muffin Man