Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > User Control - Having the collections show up in property window

Reply
Thread Tools

User Control - Having the collections show up in property window

 
 
Jay Douglas
Guest
Posts: n/a
 
      11-02-2003
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.WebControls;
using System.ComponentModel;
using System.Collections;


namespace DropDownMenuControl
{
/// <summary>
/// Summary description for DropDownMenu.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}ropDownMenu runat=server></{0}ropDownMenu>")]
public class DropDownMenu : System.Web.UI.WebControls.WebControl
{
private MenuList menuList = null;
private string text = string.Empty;

[
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true)
]
public MenuList Menu
{
get
{
if(menuList == null)
{
menuList = new MenuList();
}
return menuList;

}
}

[Bindable(true),
Category("Appearance"),
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(HtmlTextWriter output)
{
output.Write(Text);
}

}



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(MenuCategory menuCategory)
{
categories.AddCategory(menuCategory);
}

}


public class MenuCategories : IEnumerable
{

private ArrayList categories = new ArrayList();

public MenuCategories()
{
//
// TODO: Add constructor logic here
//
}

public int Count
{
get
{
return categories.Count;
}
}

public void AddCategory(MenuCategory category)
{
categories.Add(category);
}

public IEnumerator GetEnumerator()
{
return new MenuCategoriesEnumerator(categories);

}
}


public class MenuCategoriesEnumerator : IEnumerator
{

private ArrayList categories = new ArrayList();
private int position = -1;

public MenuCategoriesEnumerator(ArrayList categories)
{
this.categories = categories;
}

public object Current
{
get
{
return categories[position];

}
}

public bool MoveNext()
{
if (position < categories.Count - 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(MenuCommand menuCommand)
{
commands.AddCommand(menuCommand);
}

}

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(MenuCommand menuCommand)
{
commands.Add(menuCommand);
}

public IEnumerator GetEnumerator()
{
return new MenuCommandsEnumerator(commands);

}
}


public class MenuCommandsEnumerator : IEnumerator
{

private ArrayList commands = new ArrayList();
private int position = -1;

public MenuCommandsEnumerator(ArrayList 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="commandText">Text that is displayed in the menu
command</param>
/// <param name="commandUrl">The url that the menu command
launches</param>
public MenuCommand(string 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




 
Reply With Quote
 
 
 
 
Jay Douglas
Guest
Posts: n/a
 
      11-02-2003
I was creating the collection all wrong. I finally found my solution at:
http://groups.google.com/groups?hl=e...906a51a&rnum=3

--
Jay Douglas
Fort Collins, CO



"Jay Douglas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.WebControls;
> using System.ComponentModel;
> using System.Collections;
>
>
> namespace DropDownMenuControl
> {
> /// <summary>
> /// Summary description for DropDownMenu.
> /// </summary>
> [DefaultProperty("Text"),
> ToolboxData("<{0}ropDownMenu runat=server></{0}ropDownMenu>")]
> public class DropDownMenu : System.Web.UI.WebControls.WebControl
> {
> private MenuList menuList = null;
> private string text = string.Empty;
>
> [
>

DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
> PersistenceMode(PersistenceMode.InnerProperty),
> NotifyParentProperty(true)
> ]
> public MenuList Menu
> {
> get
> {
> if(menuList == null)
> {
> menuList = new MenuList();
> }
> return menuList;
>
> }
> }
>
> [Bindable(true),
> Category("Appearance"),
> 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(HtmlTextWriter output)
> {
> output.Write(Text);
> }
>
> }
>
>
>
> 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(MenuCategory menuCategory)
> {
> categories.AddCategory(menuCategory);
> }
>
> }
>
>
> public class MenuCategories : IEnumerable
> {
>
> private ArrayList categories = new ArrayList();
>
> public MenuCategories()
> {
> //
> // TODO: Add constructor logic here
> //
> }
>
> public int Count
> {
> get
> {
> return categories.Count;
> }
> }
>
> public void AddCategory(MenuCategory category)
> {
> categories.Add(category);
> }
>
> public IEnumerator GetEnumerator()
> {
> return new MenuCategoriesEnumerator(categories);
>
> }
> }
>
>
> public class MenuCategoriesEnumerator : IEnumerator
> {
>
> private ArrayList categories = new ArrayList();
> private int position = -1;
>
> public MenuCategoriesEnumerator(ArrayList categories)
> {
> this.categories = categories;
> }
>
> public object Current
> {
> get
> {
> return categories[position];
>
> }
> }
>
> public bool MoveNext()
> {
> if (position < categories.Count - 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(MenuCommand menuCommand)
> {
> commands.AddCommand(menuCommand);
> }
>
> }
>
> 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(MenuCommand menuCommand)
> {
> commands.Add(menuCommand);
> }
>
> public IEnumerator GetEnumerator()
> {
> return new MenuCommandsEnumerator(commands);
>
> }
> }
>
>
> public class MenuCommandsEnumerator : IEnumerator
> {
>
> private ArrayList commands = new ArrayList();
> private int position = -1;
>
> public MenuCommandsEnumerator(ArrayList 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="commandText">Text that is displayed in the menu
> command</param>
> /// <param name="commandUrl">The url that the menu command
> launches</param>
> public MenuCommand(string 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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to post the data to a new window and control the new window's property? Matt ASP .Net 2 08-23-2004 05:29 PM
How to post the data to a new window and control the new window's property? Matt Java 1 08-22-2004 09:09 PM
User Control - Having the collections show up in property window Jay Douglas ASP .Net 1 11-02-2003 07:03 PM
Sorting collections based on nested collections Doug Poland Java 9 09-27-2003 10:46 PM
InnerProperty Persistance for Collections containing other Collections mutex ASP .Net Building Controls 0 07-27-2003 02:45 PM



Advertisments