0

I was wondering if anyone can point me in the right direction. I have an asp.net button with a click event (that runs some server side code). I want to change the button, so that when clicked, it turn grey and disabled for 3 seconds, but it will also run server code at the same time. But, the button will change color if it postback.

Thanks for guidance!

eric
  • 147
  • 2
  • 4
  • 12
  • https://stackoverflow.com/questions/5189593/disable-asp-net-button-after-click-to-prevent-double-clicking – Mike May 30 '18 at 03:14

1 Answers1

0

You can use jquery setTimeout to disable button for 3 second like this.

$('#YourButtonID').click(function(){
    var yourBtn = $(this);
    yourBtn.prop('disabled', true);
    setTimeout(function(){
        yourBtn.prop('disabled', false);
    }, 3000);
});

To get ID :

$("#<%=YourButtonID.ClientID%>")

Or you can use class .

4b0
  • 21,981
  • 30
  • 95
  • 142