eljon_i3
eljon_i3

Reputation: 169

How to disable button in ASP.NET

I have an onclick code on my image to disable the button on my form that look like this

<img alt="" src="images/search-icon.png" width="16" height="16" style="display: inline;height:16px;cursor:pointer; width: 16px;" onclick="DisableButton('<%=btnSave.ClientID %>');" />

And then on my javascript I have a code like this

function DisableButton(bSave) {
document.getElementById(bSave).attributes("Enabled", false);
}

the problem is it is not working, everytime i click on the image nothing happens. Is there an error on my code? Please help me on this one. Thank you in advance.

Upvotes: 0

Views: 103

Answers (3)

Arunprasanth K V
Arunprasanth K V

Reputation: 21931

Please use this it will work In your script :

document.getElementById(bSave).disabled = true;

if you are using jquery then

 $("#"bSave).prop("disabled",true);

Upvotes: 0

Lucky
Lucky

Reputation: 609

Use 'disabled'

document.getElementById(bSave).disabled = true;

http://www.w3schools.com/jsref/prop_html_disabled.asp

Clearing up the disable vs disabled ambiguity.

Upvotes: 1

Rahul Nikate
Rahul Nikate

Reputation: 6337

Here's code :

 document.getElementById(bSave).disabled = true;

Or

document.getElementById('<%= btnSave.ClientID %>').disabled = true;

Upvotes: 0

Related Questions