Hello, 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).
Basically, we want to have a custom control named WebPart
which is an abstract class that our web parts derive from.
In the WebPart
class I want for it to basically just contain a title and content(both being capable of having style sheets applied).
Right now I basically just have in the WebPart
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.
The only solution I see is doing something like having a Panel
for both the title and content and then overriding WebPart.Controls
so that Controls=pnlContent.Controls
.
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?
What problems can be encountered by overriding a custom control's Control
indexer to point at another control's Control
property?
My proposed class would be something like this(simplified a lot)
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);
}
}
Also, Would ASP.Net have problems rendering this because I hide the base.Controls property? (thus, would it only render pnlContent.Controls
and not this.Controls
?)