I need help getting the collections to show up in the property window of a
user control. I want to be able to edit the collection items just like any
other asp.net control that has collection properties (i.e. The ASP:Table
control). This is for a menu system. The collections are working when the
classes are called directly, but not as a user control. Any advice is
appreciated.
Code:
------
using System;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Componen tModel;
using System.Collecti ons;
namespace DropDownMenuCon trol
{
/// <summary>
/// Summary description for DropDownMenu.
/// </summary>
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:DropDownMenu runat=server></{0}:DropDownMen u>")]
public class DropDownMenu : System.Web.UI.W ebControls.WebC ontrol
{
private MenuList menuList = null;
private string text = string.Empty;
[
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
PersistenceMode (PersistenceMod e.InnerProperty ),
NotifyParentPro perty(true)
]
public MenuList Menu
{
get
{
if(menuList == null)
{
menuList = new MenuList();
}
return menuList;
}
}
[Bindable(true),
Category("Appea rance"),
DefaultValue("" )]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlText Writer output)
{
output.Write(Te xt);
}
}
public class MenuList
{
private MenuCategories categories = new MenuCategories( );
public MenuList()
{
//
// TODO: Add constructor logic here
//
}
public MenuCategories MenuCategories
{
get
{
return categories;
}
set
{
categories = value;
}
}
public void AddCategory(Men uCategory menuCategory)
{
categories.AddC ategory(menuCat egory);
}
}
public class MenuCategories : IEnumerable
{
private ArrayList categories = new ArrayList();
public MenuCategories( )
{
//
// TODO: Add constructor logic here
//
}
public int Count
{
get
{
return categories.Coun t;
}
}
public void AddCategory(Men uCategory category)
{
categories.Add( category);
}
public IEnumerator GetEnumerator()
{
return new MenuCategoriesE numerator(categ ories);
}
}
public class MenuCategoriesE numerator : IEnumerator
{
private ArrayList categories = new ArrayList();
private int position = -1;
public MenuCategoriesE numerator(Array List categories)
{
this.categories = categories;
}
public object Current
{
get
{
return categories[position];
}
}
public bool MoveNext()
{
if (position < categories.Coun t - 1)
{
position ++;
return true;
}
else
{
return false;
}
}
public void Reset()
{
position = -1;
}
}
public class MenuCategory
{
private MenuCommands commands = new MenuCommands();
//private ArrayList categories = new ArrayList();
public MenuCategory()
{
//
// TODO: Add constructor logic here
//
}
public string HeaderText = string.Empty;
public string HeaderUrl = string.Empty;
public MenuCommands Commands
{
get
{
return commands;
}
set
{
commands = value;
}
}
public void AddCommand(Menu Command menuCommand)
{
commands.AddCom mand(menuComman d);
}
}
public class MenuCommands : IEnumerable
{
private ArrayList commands = new ArrayList();
public MenuCommands()
{
//
// TODO: Add constructor logic here
//
}
public int Count
{
get
{
return commands.Count;
}
}
public void AddCommand(Menu Command menuCommand)
{
commands.Add(me nuCommand);
}
public IEnumerator GetEnumerator()
{
return new MenuCommandsEnu merator(command s);
}
}
public class MenuCommandsEnu merator : IEnumerator
{
private ArrayList commands = new ArrayList();
private int position = -1;
public MenuCommandsEnu merator(ArrayLi st menuCommands)
{
commands = menuCommands;
}
public object Current
{
get
{
return commands[position];
}
}
public bool MoveNext()
{
if (position < commands.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}
public void Reset()
{
position = -1;
}
}
public class MenuCommand
{
private string text = "";
private string url = "";
/// <summary>
/// Create a new menu command
/// </summary>
/// <param name="commandTe xt">Text that is displayed in the menu
command</param>
/// <param name="commandUr l">The url that the menu command
launches</param>
public MenuCommand(str ing commandText, string commandUrl)
{
text = commandText;
url = commandUrl;
}
/// <summary>
/// Text that is displayed in the menu command
/// </summary>
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// The url that the menu command launches
/// </summary>
public string Url
{
get
{
return url;
}
set
{
url = value;
}
}
}
}
--
Jay Douglas
Fort Collins, CO
user control. I want to be able to edit the collection items just like any
other asp.net control that has collection properties (i.e. The ASP:Table
control). This is for a menu system. The collections are working when the
classes are called directly, but not as a user control. Any advice is
appreciated.
Code:
------
using System;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Componen tModel;
using System.Collecti ons;
namespace DropDownMenuCon trol
{
/// <summary>
/// Summary description for DropDownMenu.
/// </summary>
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:DropDownMenu runat=server></{0}:DropDownMen u>")]
public class DropDownMenu : System.Web.UI.W ebControls.WebC ontrol
{
private MenuList menuList = null;
private string text = string.Empty;
[
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
PersistenceMode (PersistenceMod e.InnerProperty ),
NotifyParentPro perty(true)
]
public MenuList Menu
{
get
{
if(menuList == null)
{
menuList = new MenuList();
}
return menuList;
}
}
[Bindable(true),
Category("Appea rance"),
DefaultValue("" )]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlText Writer output)
{
output.Write(Te xt);
}
}
public class MenuList
{
private MenuCategories categories = new MenuCategories( );
public MenuList()
{
//
// TODO: Add constructor logic here
//
}
public MenuCategories MenuCategories
{
get
{
return categories;
}
set
{
categories = value;
}
}
public void AddCategory(Men uCategory menuCategory)
{
categories.AddC ategory(menuCat egory);
}
}
public class MenuCategories : IEnumerable
{
private ArrayList categories = new ArrayList();
public MenuCategories( )
{
//
// TODO: Add constructor logic here
//
}
public int Count
{
get
{
return categories.Coun t;
}
}
public void AddCategory(Men uCategory category)
{
categories.Add( category);
}
public IEnumerator GetEnumerator()
{
return new MenuCategoriesE numerator(categ ories);
}
}
public class MenuCategoriesE numerator : IEnumerator
{
private ArrayList categories = new ArrayList();
private int position = -1;
public MenuCategoriesE numerator(Array List categories)
{
this.categories = categories;
}
public object Current
{
get
{
return categories[position];
}
}
public bool MoveNext()
{
if (position < categories.Coun t - 1)
{
position ++;
return true;
}
else
{
return false;
}
}
public void Reset()
{
position = -1;
}
}
public class MenuCategory
{
private MenuCommands commands = new MenuCommands();
//private ArrayList categories = new ArrayList();
public MenuCategory()
{
//
// TODO: Add constructor logic here
//
}
public string HeaderText = string.Empty;
public string HeaderUrl = string.Empty;
public MenuCommands Commands
{
get
{
return commands;
}
set
{
commands = value;
}
}
public void AddCommand(Menu Command menuCommand)
{
commands.AddCom mand(menuComman d);
}
}
public class MenuCommands : IEnumerable
{
private ArrayList commands = new ArrayList();
public MenuCommands()
{
//
// TODO: Add constructor logic here
//
}
public int Count
{
get
{
return commands.Count;
}
}
public void AddCommand(Menu Command menuCommand)
{
commands.Add(me nuCommand);
}
public IEnumerator GetEnumerator()
{
return new MenuCommandsEnu merator(command s);
}
}
public class MenuCommandsEnu merator : IEnumerator
{
private ArrayList commands = new ArrayList();
private int position = -1;
public MenuCommandsEnu merator(ArrayLi st menuCommands)
{
commands = menuCommands;
}
public object Current
{
get
{
return commands[position];
}
}
public bool MoveNext()
{
if (position < commands.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}
public void Reset()
{
position = -1;
}
}
public class MenuCommand
{
private string text = "";
private string url = "";
/// <summary>
/// Create a new menu command
/// </summary>
/// <param name="commandTe xt">Text that is displayed in the menu
command</param>
/// <param name="commandUr l">The url that the menu command
launches</param>
public MenuCommand(str ing commandText, string commandUrl)
{
text = commandText;
url = commandUrl;
}
/// <summary>
/// Text that is displayed in the menu command
/// </summary>
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// The url that the menu command launches
/// </summary>
public string Url
{
get
{
return url;
}
set
{
url = value;
}
}
}
}
--
Jay Douglas
Fort Collins, CO
Comment