I have seen stackoverflow ask question page they disable button until my postback event is finished when i post the question and redirect me to my question page... How to do this in asp.net/jquery?
views:
57answers:
2
+2
A:
$('#myform').submit(function(){
$('input[type=submit]', this).attr('disabled', 'disabled');
});
to re-enable your button after a client side action has completes, such as AJAX:
$('#myform:input[type=submit]').removeAttr('disabled');
Glennular
2010-04-16 05:09:11
@Glennar will this keep my button diasabled until postback finishes..
chandru_cp
2010-04-16 05:10:37
yes... as the attribute won't be persisted to the viewstate, the button will be enabled after postback again. one thing to be aware off: sometimes (especially with asp.net postbacks) there's no call of the submit-eventHandler
Andreas Niedermair
2010-04-16 05:31:22
A:
The basic concept is that you would have jquery add a client-side click event which disabled the button (i.e. $('#controlName').attr("disabled", "disabled"); ). What thing to remember is that you want to return TRUE from that method, so that the standard form post functionality will still work.
Something like:
$(function(){
$('#controlName').click(function(){
$('#controlName').attr("disabled", "disabled");
return true;
});
});
Stephen Wrighton
2010-04-16 05:10:14
@Stephen what happens when my client side functionality finishes and goes server side will the button be still disabled.......
chandru_cp
2010-04-16 05:13:25