Reputation: 5660
Without using jQuery (can't get into why NOT right now) how do I disable an ASP.NET button from being "clickable" if a certain client-side condition is not met?
Upvotes: 0
Views: 398
Reputation: 761
OnClientClick="return false;" will prevent the post back, without disabling the button. And you can add an alert('button disabled') if wanted.
Upvotes: 2
Reputation: 33143
Use javascript:
document.form1.button.disabled=true;
or try
document.getElementByID('myButton').disabled=true;
Upvotes: 1
Reputation: 108937
You can do something like this with pure javascript.
if(someCondition)
document.getElementById("buttonClientID").disable = true;
else
document.getElementById("buttonClientID").disable = false;
Upvotes: 2
Reputation: 23132
The button will be rendered as an <input>
tag on the client side. Find the input using the standard JavaScript document.getElementById and set its disabled
property to true
.
Upvotes: 2