Daniel Coffman
Daniel Coffman

Reputation: 2005

Disable LinkButton when OnClick Event Fires

I have an asp:LinkButton as follows:

<asp:LinkButton ID="LinkButtonNewServicesCategory" runat="server" 
    OnClientClick="this.disabled=true;return false;" 
    style="float:left;margin-right:5px;" CausesValidation="False">new services category</asp:LinkButton> 

The intent is that when the LinkButton is clicked, it disables itself and returns false to prevent the postback (this control is used as a trigger for an animation).

The behavior I'm experiencing is that the LinkButton correctly triggers the animation and returns false, but does not disable itself.

It's inside an updatepanel, but I'm sure that no postback is occurring.

Why doesn't this.disabled=true work?

Upvotes: 0

Views: 3598

Answers (1)

tbeseda
tbeseda

Reputation: 1857

I'm not familiar with the way asp.net interacts with js but to disable an element with javascript use:

this.disabled=disabled; // not disabled=true

Then, to enable it again, remove the disabled attribute.

Upvotes: 2

Related Questions