asp:Label with nested control disappears on setting CssClass
<p>Is it improper to nest another control within asp:Label?</p>

<p>When I have another control (e.g., a button) inside my asp:Label, and I try to change CssClass on the label during an event handler, the entire label seems to disappear. I'll be grateful if someone can help me find what I might be doing wrong.</p>

<p>Bad1.aspx:</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Bad1.aspx.cs" Inherits="Bad1" %&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;Badness?&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
        &lt;asp:CheckBox ID="CheckBox1" runat="server" Text="check and uncheck me" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" /&gt; 
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;asp:Label ID="Label1" runat="server" &gt; See me now? &lt;asp:Button runat="server" /&gt; &lt;/asp:Label&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Bad1.aspx.cs:</p>

<pre><code>using System;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Bad1 : System.Web.UI.Page 
{
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        var lab = Page.FindControl("Label1") as Label;
        lab.CssClass = "foo";
    }
}
</code></pre>

<p>Symptom: Page displays correctly at first, and after first click on "check and uncheck me". But when I click on the checkbox a second time, the label ("See me now") disappears, never to come back. If I remove the button from within the label, there's no problem. So, is the nesting what's incorrect?</p>
