views:

110

answers:

1

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?

+2  A: 

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.

tb
Upvoting for probably correct answer, but I'm not testing (and thus can verify correctness) because I solved my problems in a much more elegant way since posting this question 24 minutes ago.
Daniel Coffman
`this.disabled = true;` //to disable it, not `this.disabled = disabled;` ... ; )
rlb.usa
Danile, why don't you post your more elegant solution then?
Jack Marchetti