M
Matt Winward
I'm really stuck with a Composite Control and I could really do with
some pointers if anyone's willing.
My control has a public property as follows:
/// <summary>
/// Gets a list of all the menu items (not including Home or Login).
/// </summary>
[Category("Behaviour")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
[NotifyParentProperty(true)]
[ReadOnly(true)]
public List<MainMenuItem> MenuItems
{
get
{
if (_menuitems == null) _menuitems = new List<MainMenuItem>();
return _menuitems;
}
}
When CreateChildControls() fires, I go through this list and populate
the main menu accordingly. Each MainMenuItem is, in turn, another
Composite Control.
If I drop a MainMenu control onto the design-time canvas, it goes on
fine. I can then go to MenuItems in the properties pain, click on the
ellipsis and add a load of MainMenuItem controls and the control
updates itself with these new controls.
The problem is that if I go to the HTML and change anything, like
removing one of the menu items, for example, and then go back to the
Design view, the control throws the following error:
'MenuItems' could not be initialized. Details: 'MenuItems' could not
be added to the collection. Details: Object does not match target
type.
I've been trawling the net for days but can't work out why this error
is appearing and what I need to do to rectify it.
Any help would be greatly appreciated!!
Matt
some pointers if anyone's willing.
My control has a public property as follows:
/// <summary>
/// Gets a list of all the menu items (not including Home or Login).
/// </summary>
[Category("Behaviour")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
[NotifyParentProperty(true)]
[ReadOnly(true)]
public List<MainMenuItem> MenuItems
{
get
{
if (_menuitems == null) _menuitems = new List<MainMenuItem>();
return _menuitems;
}
}
When CreateChildControls() fires, I go through this list and populate
the main menu accordingly. Each MainMenuItem is, in turn, another
Composite Control.
If I drop a MainMenu control onto the design-time canvas, it goes on
fine. I can then go to MenuItems in the properties pain, click on the
ellipsis and add a load of MainMenuItem controls and the control
updates itself with these new controls.
The problem is that if I go to the HTML and change anything, like
removing one of the menu items, for example, and then go back to the
Design view, the control throws the following error:
'MenuItems' could not be initialized. Details: 'MenuItems' could not
be added to the collection. Details: Object does not match target
type.
I've been trawling the net for days but can't work out why this error
is appearing and what I need to do to rectify it.
Any help would be greatly appreciated!!
Matt