2

On an ASPX.Page, I have a button that performs a postback. User must be prevented from clicking it more than once. I want to do this with jQuery but

jQuery(document).ready(function() {

        $('#<%= saveButton.ClientID  %>').click(function() { $(this).attr('disabled', 'true'); });

    });

doesn´t work for me because the button does not postback. Is there an easy way to prevent a second click while still keeping the functionality of the button?

1
  • Don't get the "the button does not postback"-part. When are you running the given statement? At button click? Commented Jan 13, 2011 at 12:00

3 Answers 3

4
$('form').submit(function(){
    // On submit disable its submit button
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

http://jquery-howto.blogspot.com/2009/05/disable-submit-button-on-form-submit.html

Or you could block the whole user-interface with jQuery. therefore you need this plugin.

// To lock user interface
$.blockUI();

// To unlock user interface
$.unblockUI();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, the plug-in is quite what I looked for.
0

You can place button in DIV and using JavaScript you can hide div.

document.getElementById('div1').style.display = "none";

HOpe it will solve your problem.

Comments

0

I would suggest hiding the button on click. Disabling it won't fire the server side event. Just hide the button when it is clicked. After postback it will show itself as expected. How to disable button on postback would solve your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.