CompositeControl design time list problems when altering HTML (Objectdoes not support target type)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top