title: ASP.NET single quotes are converted to &#39;
body: <p>Note: Most probably this will be a double question, but since I haven't found a clear answer, I'm asking it anyway. </p>
  
  <p>In ASP.NET I'd like to add some JavaScript to the onclick event of a CheckBox. I've simplified the case to this:</p>
  
  <pre><code>&lt;asp:CheckBox ID="TestCheckBox" runat="server" onclick="alert('test');" Text="Test" /&gt;
  </code></pre>
  
  <p>The resulting HTML is as follows:</p>
  
  <pre><code>&lt;input id="MainContainer_TestCheckBox" type="checkbox" name="ctl00$MainContainer$TestCheckBox" onclick="alert(&amp;#39;test&amp;#39;);" /&gt;&lt;label for="MainContainer_TestCheckBox"&gt;Test&lt;/label&gt; 
  </code></pre>
  
  <p>What particularly bothers me is that a single quote 'automatically' gets converted into '&amp;#39;'. If I omit the onclick in the markup and assign it in Page_Load, the exact same results show in the HTML.</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      this.TestCheckBox.Attributes["onclick"] = "alert('test');";
  }
  </code></pre>
  
  <p>Anyone got a clue about what's happening? Or how to fix/ avoid it? </p>