Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 655275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:35:09+00:00 2026-05-13T22:35:09+00:00

I’m trying to stop postback on form submit if my custom jQuery validation returns

  • 0

I’m trying to stop postback on form submit if my custom jQuery validation returns false.

Is there any way to prevent the __doPostback() function finishing from within the submit() function?

I’d assumed:

$('#aspnetForm').submit(function () { return false; });

would do the trick, but apparently that’s not the case: does anyone have a suggestion?

The submit() function does block the postback (it won’t postback if you pause at a breakpoint in firebug), but I can’t seem to stop the event happening after the submit() function is complete!

Cheers, Ed

EDIT

OK, I had a quick mess about and discovered that the fact that the button I’m using to cause the postback is tied to an updatepanel as an asyncpostbacktrigger seems to be the problem: If I remove it as a trigger (i.e. cause it to product a full postback), the is no problem preventing the postback with return false;

Any ideas why the async postback would not be stoppable using return false?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:35:09+00:00Added an answer on May 13, 2026 at 10:35 pm

    You have to use the client side PageRequestManager to properly handle AJAX submit events. (e.g. prevent an async postback.)

    If you are not in total control of the page, there can be JavaScript on the page that just calls __doPostBack() without going through any page logic.
    In this case – in addition to the above -, you have to store the old window.__doPostBack() and provide your own – as @tucaz mentioned in his comments.
    (…and as you mentioned, it can get quite perplexing with chaining.)
    For regular submits (non-AJAX), you can provide an event handler as others have pointed out.

    This page might be of help and has some code samples that use PageRequestManager. In particular:

    initialize : function()
    {
        ...
    
        this._onSubmitHandler = Function.createDelegate(this, this._onSubmit);
        this._onPartialUpdateEnd = Function.createDelegate(this, this._onUpdateEnd);
    
        if (typeof(Sys.WebForms)!== "undefined" && typeof(Sys.WebForms.PageRequestManager)!== "undefined")
        {
            Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, this._onSubmitHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(this._onPartialUpdateEnd);
        }
        else 
            $addHandler(document.forms[0], "submit", this._onSubmitHandler);
    },
    

    Edit:
    Following the above, this, for example works fine for me (.Net 3.5 SP1, Button1 is trigger in the updatepanel, etc…):

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js" charset="utf-8"
            type="text/javascript"></script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div>
                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button1" />
            </Triggers>
        </asp:UpdatePanel>
        </form>
        <script type="text/javascript">
            (function($, undefined) {
    
                var submitHandler = function(e) {
                    return false;
                }
    
                if (typeof (Sys.WebForms) !== "undefined" && typeof (Sys.WebForms.PageRequestManager) !== "undefined") {
                    Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, submitHandler);
                } else {
                    $("form").submit(submitHandler);
                }
            })(jQuery);
        </script>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are two command line utilities that are helpful in… May 16, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer <ul id="MyMenu"> <li> info 1 <ul class="inner"> <li>apple1</li> <li>mango1</li> <li>banana1</li>… May 16, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer You are trying to create the Run in the background… May 16, 2026 at 11:40 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.