Best way to disable all submit buttons after postback

I am trying to write code that will disable the submit button (or all submit buttons) on the page to avoid double postback.

I was thinking of creating my own javascript function for postback (and using postback javascript with GetPostbackEventReference), but maybe there are some better ways to do this? Or maybe there is another way to avoid double reverse gears?

Update

I also want to find a better place to call javascript, for example. if I call the following script in the onclick button handler, then the server button click event will not be connected.

$('input[type=submit]').attr('disabled', 'disabled')
+3
source share
3

http://greatwebguy.com/programming/dom/prevent-double-submit-with-jquery/

   1. $('form').submit(function(){  
   2.     $(':submit', this).click(function() {  
   3.         return false;  
   4.     });  
   5. });  
+4

JQuery

$('input[type=submit]').attr('disabled', 'disabled')

document.getElementByTagName('input')

, , , ?

+2

How about this:

$('input[type=button]').click(function() {
    $('input[type=button]').each(function() {
        $(this).attr('disabled', 'disabled')
    });
});

Each time you press any button, each button in the form is disabled.

0
source

Source: https://habr.com/ru/post/1775180/


All Articles