Problem
This is because there is no attribute
disabled
present inside the
HTML
rendered as you have a property
Enabled="false"
. So, it renders something like below.
<a class="aspNetDisabled NextButton" id="Lnk_Orgnz"><div class="nbpad">Next</div></a>
As there is no
disabled
attribute, so it is unable to remove that.
Solution
Remove the
Enabled="false"
from the Mark-Up. So,
LinkButton
will be like below.
<asp:LinkButton ID="Lnk_Orgnz" ValidationGroup="CmpName" ClientIDMode="Static" OnClick="SubmitPart1"
runat="server" CssClass="NextButton"><div class="nbpad">Next</div></asp:LinkButton>
Now, you have to disable it using
jQuery
, so do like below.
var _href;
$(document).ready(function () {
_href = $('[id$=Lnk_Orgnz]').attr('href');
$('[id$=Lnk_Orgnz]').attr('disabled', 'disabled');
$('[id$=Lnk_Orgnz]').removeAttr('href');
});
As a result of this, the
HTML
renders like below.
<a class="NextButton" id="Lnk_Orgnz" disabled="disabled"><div class="nbpad">Next</div></a>
Now, it has
disabled
attribute, so you can remove it if you want to Enable it.
To Enable the LinkButton, use the below code.
$('[id$=Lnk_Orgnz]').removeAttr('disabled');
$('[id$=Lnk_Orgnz]').attr('href', _href);
Note:- we are removing the disabled attribute and adding the href attribute again, which is added to
LinkButton
when it is first created.
Hope it solves you issue. I have tested it at my end; it's working fine.
In case of any questions or doubt, feel free to ask me.