I have control that has a list of items with subitems. I need to have a recursive function that collects the sub items.
e.g How do I collect and iterate this collection that has sub items? is an ArrayList MenuItems the appropriate Type to use?<myControl:Menu id="MyControl" runat="server">
<mycontrol:MenuItem Text="Hellow World">
<mycontrol:MenuItem Text="Hellow World">
<mycontrol:MenuItem Text="Hellow World" />
</myControl:menuItem>
</myControl:menuItem>
</myControl:Menu>
Here is the control:
public class QuickControl: WebControl
{
private ArrayList MenuItems;
[
Category("Behavior"),
Description("The contacts collection"),
DesignerSerializationVisibility(
DesignerSerializationVisibility.Content),
Editor(typeof(MenuCollectionEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
public ArrayList MenuItems
{
get
{
if (MenuList == null)
{
MenuList = new ArrayList();
}
return MenuList;
}
}
// The contacts are rendered in an HTML table.
protected override void RenderContents(
HtmlTextWriter wri开发者_JS百科ter)
{
Table t = CreateContactsTable();
if (t != null)
{
t.RenderControl(writer);
}
}
}
精彩评论