title: JavaScript disabled = true vs ASP.NET Enabled = False
body: <p>In my ASP.NET web application, I have some elements that may be disabled in code-behind and some elements may be disabled in JavaScript.</p>
  
  <p>For the code-behind elements, I simply use the following VB.NET property:</p>
  
  <pre><code>Me.element1.Enabled = False
  </code></pre>
  
  <p>For the dynamic elements, I use the following JavaScript property:</p>
  
  <pre><code>document.getElementById('" &amp; Me.element2.ClientID &amp; "').disabled = true;
  </code></pre>
  
  <p>The first thing I noticed is that changing the Enabled property doesn't just add <code>disabled="disabled"</code> to the markup, it also changes the class from <code>button</code> (my skinned class name for buttons) to <code>button aspNetDisabled</code>.  To compensate for this, I include the following additional JavaScript line:</p>
  
  <pre><code>document.getElementById('" &amp; Me.element2.ClientID &amp; "').className = 'button aspNetDisabled';
  </code></pre>
  
  <p>(Clearly, this means I need to maintain the className attribute if/when I enable the element again, and I'll need to ensure I use <code>button</code>/<code>textbox</code>/etc. as applicable - For bonus points, if you have any recommendations about this, I'd be happy to hear them)</p>
  
  <p><strong>However, I also noticed that the markup produced via JavaScript is only <code>disabled=""</code>, whereas the markup produced by the ASP.NET Enabled property change is <code>disabled="disabled"</code>.</strong></p>
  
  <p>I tried fiddling with the JavaScript to change it to:</p>
  
  <pre><code>document.getElementById('" &amp; Me.element2.ClientID &amp; "').disabled = 'disabled';
  </code></pre>
  
  <p>However, this didn't seem to make a difference, with the attribute still being empty.  Interesting that <code>disabled=true;</code> and <code>disabled='disabled';</code> seem to work in the same way - I expect one of them is more correct (I'm sticking to <code>=true;</code> for now).</p>
  
  <p><strong>Is there a recommended best way of achieving the same results with JavaScript as with server-side ASP.NET with regards to enabling and disabling elements?</strong></p>
  
  <p>and...</p>
  
  <p><strong>Is the difference between the rendering of <code>disabled="disabled"</code> and <code>disabled=""</code> likely to cause me any problems?</strong></p>