Last post Sep 15, 2008 10:45 AM by Peter Bucher
Sep 12, 2008 04:39 PM|dgoyette|LINK
I've been working on what should have been a fairly simple project, but it's gotten rather complicated and challenging. Essentially, I'm trying to make a Server Control (not a user control) that is basically a panel with some extra formatting (a title bar).
I want to be able to drag and drop this onto my form, and drop other controls into it, just like a normal Panel.
In my research so far, I've found a way to do this, but I don't think it's the right way. Basically, my question can be boiled down to this:
What is the right way to create a Server Control Container, such that there are various controls added before and after the other controls that are dropped into the panel?
My first attempt has me using CreateChildControls. Here's what I do:
protected override void CreateChildControls()
Control controls = new Control[Controls.Count];
// Create my Title controls here, and add them to Controls.
_bodyPanel = new Panel();
_bodyPanel.ID = "bodyPanel";
_bodyPanel.CssClass = BodyCssClass;
foreach (Control c in controls)
This seems to work for the most part, but not quite the way I want it to work. My real question is about the existing controls that I'm copying into another array, then adding in after. Is there a better way to do that?
Sep 14, 2008 06:20 PM|jkirkerx|LINK
There are several post a week for the same subject. Look through the previous post in the forum, and you'll find many posts with sample code and explanations.
Most of them are under template controls,
Many programmers seem to want the same thing so it's a common subject. Peter Bucher always answers this question, he knows how to do it.
Sep 15, 2008 10:45 AM|Peter Bucher|LINK
The Panel-Control is done with the attribute "ParseChildren(true)", but that implies only one content-area.
If you want more of them, use templates for accomplish that kind of task.
Keywords: ITemplate, TemplateInstance-Attribute, PersistenceMode-Attribute