title: ASP.Net Checkbox value at postback is wrong?
body: <p>We have a checkbox that is initially disabled and checked. It is then enabled on the client side through javascript. If the user then unchecks the box and presses the button to invoke a postback, the state of the checkbox remains as checked on the server side. This is obviously undesirable behaviour. Here is an example.</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testcb.aspx.cs" Inherits="ESC.testcb" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
  
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;script type="text/javascript"&gt;
          function buttonClick() {
              var cb = document.getElementById('&lt;%= CheckBox1.ClientID %&gt;');
              cb.disabled = false;
              cb.parentNode.disabled = false;
          }
  
  
      &lt;/script&gt;
  
      &lt;div&gt;
          &lt;asp:CheckBox ID="CheckBox1" runat="server" Checked="true" Enabled="false" /&gt;
          &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="buttonClick(); return false;" /&gt;
          &lt;asp:Button ID="Button2" runat="server" Text="Button2" OnClick="button2Click" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the Server-side code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace ESC
  {
      public partial class testcb : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
          }
  
          protected void button2Click(object sender, EventArgs e)
          {
              string h = "";
          }
      }
  }
  </code></pre>
  
  <p>So we break at the "string h" line and check the value of CheckBox1.Checked. It is true, even if it is unchecked on the form.</p>