title: Overriding the Controls property in a custom control a bad idea?
body: <p>I am attempting to make a web-partish custom control. I am going to be using Mono, so no I can't just use ASP.Net's (thats what we were using before we decided to go Mono).</p>
  
  <p>Basically, we want to have a custom control named <code>WebPart</code> which is an abstract class that our web parts derive from. </p>
  
  <p>In the <code>WebPart</code> class I want for it to basically just contain a title and content(both being capable of having style sheets applied). </p>
  
  <p>Right now I basically just have in the <code>WebPart</code> constructor a Label and Panel being added at location 0 of Controls so that the title will get rendered(with the label going in a panel). Now, here is my problem. There is no easy way of containing the WebPart's content(which will just be plain markup and such to the derived control) so that I can apply a style class separately to only the content and only the title of the derived control. </p>
  
  <p>The only solution I see is doing something like having a <code>Panel</code> for both the title and content and then overriding <code>WebPart.Controls</code> so that <code>Controls=pnlContent.Controls</code>.</p>
  
  <p>What are the implications of this? Will this mess up UniqueIDs or javascript? Is there a better way around this? Is this a normal thing to do for a custom control?</p>
  
  <p><strong>What problems can be encountered by overriding a custom control's <code>Control</code> indexer</strong> to point at another control's <code>Control</code> property?</p>
  
  <p>My proposed class would be something like this(simplified a lot)</p>
  
  <pre><code>abstract class WebPart{
    protected lblTitle=new Label();
    protected pnlContent=new Panel();
    public ControlCollection Controls{
      get{
        return pnlContent.Controls;
      }
    }
    public WebPart(){
      base.Controls.Add(lblTitle);
      base.Controls.Add(pnlContent);
    }
  }
  </code></pre>
  
  <p>Also, Would ASP.Net have problems rendering this because I hide the base.Controls property? (thus, would it only render <code>pnlContent.Controls</code> and not <code>this.Controls</code>?)</p>