Implementing a control with child controls
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolscs' list.


Roberto Veiga
Hello, people:

I'd like to implement a control called, for instance, "ParentControl",
which in turn has a property called "ChildControls" that represents a
collection (called "ChildControlCollection") of a control called
"ChildControl", so that, when I add ChildControls to the ParentControl's
ChildControls property through the VS.NET dialog box, those ChildControls
appear as nested tags between the ParentControl tags automatically. (Similar
to that which occurs when I add TableRows to the Table's TableRows
property). See bellow:

<control:ParentControl runat="server">
<control:ChildControl runat="server>
</control:ChildControl>
<control:ChildControl runat="server>
</control:ChildControl>
<control:ChildControl runat="server>
</control:ChildControl>
</control:ParentControl>
Some idea? A simple sample will be welcome.

Regards,

Roberto

Reply to this message...
 
    
TIM ELLISON
You need minimum 3 classes:

1) ParentControl
2) ChildControl
3) ChildControlCollection

(3) needs to be a typed collection (i.e., Add, Remove, this[] indexer need
to refer to class ChildControl, inherit System.Collections.CollectionBase)

ChildControlCollection will have an internal constructor that takes a
parameter of type ParentControl. Store that in an instance field.

When the collection methods are implemented, you will redirect your calls to
ParentControl instance's control array.

Look at [I think it's called] UICollectionEditor designer attribute for the
public property in ParentControl that accesses your childcontrol collection.

For ParentControl class look at PersistChildren designer attribute.

Both ParentControl and ChildControl should inherit from
System.Web.UI.WebControls.WebControl.

Regards,

Tim Ellison
Senior Web Applications Developer,
Long and Foster Real Estate
703-359-1884
Click here to reveal e-mail address

-----Original Message-----
From: Roberto Veiga [mailto:Click here to reveal e-mail address]
Sent: Monday, May 07, 2001 9:14 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] Implementing a control with child controls

Hello, people:

I'd like to implement a control called, for instance, "ParentControl",
which in turn has a property called "ChildControls" that represents a
collection (called "ChildControlCollection") of a control called
"ChildControl", so that, when I add ChildControls to the ParentControl's
ChildControls property through the VS.NET dialog box, those ChildControls
appear as nested tags between the ParentControl tags automatically. (Similar
to that which occurs when I add TableRows to the Table's TableRows
property). See bellow:

<control:ParentControl runat="server">
<control:ChildControl runat="server>
</control:ChildControl>
<control:ChildControl runat="server>
</control:ChildControl>
<control:ChildControl runat="server>
</control:ChildControl>
</control:ParentControl>
Some idea? A simple sample will be welcome.

Regards,

Roberto

| [aspngcontrolscs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngcontrolscs.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 
System.Collections.CollectionBase
System.Web.UI.WebControls.WebControl




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com