Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In aspx page

The LinkButton is in Disable mode.
XML
<asp:LinkButton ID="Lnk_Orgnz"  ValidationGroup="CmpName" ClientIDMode="Static"  OnClick="SubmitPart1"
                       runat="server" CssClass="NextButton" Enabled="false"><div class="nbpad">Next</div></asp:LinkButton>



In jQuery

To Enable the LinkButton, I tried like below.
JavaScript
$('[id$=Lnk_Orgnz]').removeAttr('disabled'); 

or
JavaScript
$('[id$=Lnk_Orgnz]').removeAttr("disabled");


But it is still in disable mode.
Posted
v2
Comments
Can you post the rendered html for the LinkButton? You can check that by Viewing the source in Browser.
Please follow my answer.
Did you check?
Palash Mondal_ 7-Oct-13 10:26am    
You can try this answer over here: http://stackoverflow.com/a/13163923/1823841

1 solution

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.
HTML
<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.
XML
<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.
JavaScript
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.
HTML
<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.
JavaScript
$('[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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900