我有下面的JavaScript代碼禁用頁面回發期間的asp.net按鈕。我也有一個其Autopostback屬性設置爲true的下拉列表。不幸的是,當我在下拉列表中更改selectedItem時,該按鈕被禁用。當點擊時禁用asp.net按鈕
我希望只有在頁面回發是由同一個按鈕引起,但沒有頁面上的任何其他控件導致按鈕禁用。
有人請幫助我應該對下面的代碼做出什麼樣的改變來實現這一點。
<script type="text/javascript">
// Get a reference to the PageRequestManager.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Using that prm reference, hook _initializeRequest
// and _endRequest, to run our code at the begin and end
// of any async postbacks that occur.
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// Executed anytime an async postback occurs.
function InitializeRequest(sender, args) {
// Change the Container div's CSS class to .Progress.
$get('Container').className = 'Progress';
// Get a reference to the element that raised the postback,
// and disables it.
$get(args._postBackElement.id).disabled = true;
}
// Executed when the async postback completes.
function EndRequest(sender, args) {
// Change the Container div's class back to .Normal.
$get('Container').className = 'Normal';
// Get a reference to the element that raised the postback
// which is completing, and enable it.
$get(sender._postBackSettings.sourceElement.id).disabled = false;
}
</script>