title: How to add controls to a class inheriting from Panel?
body: <p>I'm creating a custom control that I want to be available from Visual Studio's toolbox. The class looks like:</p>
  
  <pre><code>[ToolboxData("&lt;{0}:CustomPanel runat=server&gt;&lt;/{0}:CustomPanel&gt;")]
  public class CustomPanel : Panel
  {
  }  
  </code></pre>
  
  <p>So far, so good. The control is inheriting from a Panel and once added to the toolbox can be easily dragged and dropped on the aspx page. What I want to do now is add new controls to this panel such as labels and some basic HTML tags. I tried the following without success:</p>
  
  <pre><code>  [ToolboxData("&lt;{0}:CustomPanel runat=server&gt;&lt;/{0}:CustomPanel&gt;")]
    public class CustomPanel : Panel
    {
      protected override void OnInit(EventArgs e)
      {
            Label name = new Label();
            name.Text = "Hello jdecuyer!";
            this.Controls.Add(name);
            base.OnInit(e);
       }
    } 
  </code></pre>
  
  <p>Any ideas?</p>