I’m trying to enable a .net LinkButton with jQuery but things have changed a little in .NET 4.0 and simply using attr(“disabled”, “disabled”) or removeAttr(“disabled”) won’t work.
Here is the button.
<asp:LinkButton ID="LinkButtonContinue" runat="server" Text="Continue" CssClass="button continue" Enabled="false"></asp:LinkButton>
This renders out like this:
<a class="aspNetDisabled button continue" id="ContentPlaceHolder1_LinkButtonContinue">Continue</a>
Note the newly added class of aspNetDisabled.
So I tried this:
jQuery(".continue").removeAttr("disabled").removeClass("aspNetDisabled");
and this:
jQuery(".continue").removeClass("aspNetDisabled");
Neither work because there is no disabled attribute to remove so I assume it uses JS to disable it?
How would I go about enabling a button with this class?
Any ideas?
Many thanks
Chris
I think the problem is, when you have a button like that generated serverside, the page gets some javascript nonsense put onto it, e.g.:
And the button will have something like
javascript:__doPostBack('id','')on the hrefI think you should try manually defining this href value serverside (or dynamically with javascript on page load, might be easier with the horrible id that gets generated).
In your instance, there is no href so nothing happens even if the anchor is not disabled.
Edit:
Would it not just be easier to avoid disabling the button serverside, and disable it with javascript when the page loads?