title: How to enable asp:LinkButton on client side
body: <p>I have asp:LinkButton, input Button defined as: </p>
  
  <pre><code>&lt;asp:LinkButton ID="lnkViewPdf" runat="server" CssClass="icoMiniTest" ClientIDMode="Static" &gt;View Office Pdf&lt;/asp:LinkButton&gt;   
  &lt;input id="Button2" type="button" value="TestEnable" onclick="TestEnable(document.getElementById('lnkViewPdf'));"  /&gt;
  </code></pre>
  
  <p>the LinkButton is initially disabled in code-behind as:</p>
  
  <pre><code>    if (!IsPostBack)
      {
          this.lnkViewPdf.Enabled = false;
      }
  </code></pre>
  
  <p>and needs to be enabled when Button2 is clicked, so I am calling javascript function to enable the link as:</p>
  
  <pre><code>function TestEnable(lnkbutton) {
          alert('TestEnable() called');
          alert(lnkbutton.id);
          lnkbutton.disabled = "";
          //$("#lnkbutton").removeAttr('disabled');  //even this doesn't work
      }
  </code></pre>
  
  <p>But I am not able to enable the linkbutton.</p>
  
  <p>Am I missing something?</p>
  
  <p>Thank you!</p>
  
  <h1><em><strong></em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__</strong></h1>
  
  <p>Anyone interested in solution to above problem:<br>
  In code-behind:</p>
  
  <pre><code>this.lnkViewPdf.Attributes["disabled"] = "disabled";
  this.lnkViewPdf.Attributes["onclick "] = "return false";
  </code></pre>
  
  <p>.js:  </p>
  
  <pre><code>function TestEnable(lnkbutton) {
           $(lnkbutton).removeAttr('disabled');
          lnkbutton.onclick = "";    
  }
  </code></pre>
  
  <p>NOTE: When setting lnkViewPdf.Enabled = false; LinkButton was being rendered as  </p>
  
  <pre><code>&lt;a id="lnkViewPdf" class="aspNetDisabled icoMiniTest"&gt;View Office Pdf&lt;/a&gt;
  </code></pre>
  
  <p>see the style class <strong>aspNetDisabled</strong>, something added by ASP.Net<br>
  However setting disabled/onclick attributes from the codebehind as shown above, render Linkbutton as:  </p>
  
  <pre><code>&lt;a id="lnkViewPdf" class="icoMiniTest" disabled="disabled" onclick ="return false" href="javascript:__doPostBack(&amp;#39;lnkViewPdf&amp;#39;,&amp;#39;&amp;#39;)"&gt;View Office Pdf&lt;/a&gt; 
  </code></pre>
  
  <p>HTH.</p>