Disable buttons on post back using jquery in .net app

Posted by Chris Lively on Stack Overflow See other posts from Stack Overflow or by Chris Lively
Published on 2010-05-21T02:09:16Z Indexed on 2010/05/21 2:10 UTC
Read the original article Hit count: 214

Filed under:
|

I have a asp.net app that I want to disable the buttons as soon as they are clicked in order to prevent multiple submissions. I'd like to use jquery for this as the site already liberally uses it anyway.

What I've tried is:

$(document).ready(function () {
    $("#aspnetForm").submit(function () {
        $('input[type=submit]', $(this)).attr("disabled", "disabled");
    })
});

The above will disable the button, and the page submits, but the asp.net button on click handler is never called. Simply removing the above and the buttons work as normal.

Is there a better way?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery