开发者

Simulate disable of button on ASP.NET page

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 functiona开发者_运维问答lity of the button?


$('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();


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜