Reputation: 11
I have 3 Buttons
in an aspx page. One for Save as Draft
, 2nd for Cancel
and 3rd for submit
.
Now I want that whenever I click on any of the 3 Buttons
then all the 3 Buttons
should get disabled.
Upvotes: 1
Views: 1891
Reputation: 1919
This can also be done using JavaScript (without jQuery). The following code uses document.querySelectorAll
which would work in all modern browsers.
var button = document.querySelectorAll('button');
[].forEach.call(button, function (btn) {
btn.addEventListener("click", function (e) {
e.preventDefault();
disableAllButtons();
return false;
});
});
function disableAllButtons(){
[].forEach.call(button, function (btn) {
btn.disabled=true;
});
}
The JSFIDDLE.
Upvotes: 0
Reputation: 24
Here is small and sweet answer.
Give common cssclass to all buttons and then use following code for OnClientClick="funDisableButtons()" event.
function funDisableButtons()
{
$(".className").attr("disabled", true);
}
Upvotes: 0
Reputation: 7490
You can do the same with jQuery
$(":submit").click( function () {
$(":submit").each( function() {
$(this).prop('disabled', true);
});
});
It will disable your buttons before starting execution of any server side code
Upvotes: 0
Reputation: 172438
You can try like this:
private void ButtonDisable(Control ct)
{
foreach(Control c in ct.Controls)
{
if (c is Button)
{
c.Enabled = false;;
}
}
}
Upvotes: 1