divert asp.net child controls

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2009-12-14T01:57:52Z Indexed on 2010/05/13 14:04 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

Hi Folks, I am trying to create an asp.net custom control that acts as a hosting container for any other controls, similar to the existing ‘Panel’ control. Basically, I need to build a web control that groups a bunch of other controls. It will consist of a header and a body pane, similar to a normal window in desktop application. The header will contain some simple text and some JavaScript driven code that shows/hides the body pane. The body pane simply hosts any number of other controls.

+------------------------------------------------------+
| User Details                               Show/Hide |
+------------------------------------------------------+
| Name:           [Eric     ]                       |
| Address:        [Some where]                         |
| Date of Birth:  [01/01/1980]                         |
|                                                      |
| (any other fields goes on)                           |
|                                                      |
|                                                      |
+------------------------------------------------------+

Ideally I want to create a control that packs the whole thing together, so at design time I could use the following markup.

<myCtl:SuperContainer runat=”server” Title=”User Details”>
    <asp:label id=”lblName” runat=”server” text=”Name:”/>
    <asp:textbox id=”txtName” runat=”server”/>
    <asp:label id=”lblDOB” runat=”server” text=”Date of Birth:”/>
    <asp:textbox id=”txtDOB” runat=”server”/>
    (…other controls definition…)
</myCtl:SuperContainer>

I plan to include two panels in my control, one for the header and another one for the body, but as you can see, the key issue is to find a way to ‘divert’ the child controls that are defined in the markup to the body panel, instead of the default parent container. I feel it can be some how simply override (manipulate) the control property, but don’t know how to properly do so.

Can any one give some idea about how to implement this ‘SuperContainer’ control?

Many thank,

Eric

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about composite