Collection properties in web controls

H

Harlan Messinger

Suppose I have a collection class MyCollection (which implements IList)
a custom web control class MyControl that includes a property Items of
type MyCollection that will contain objects of class MyItem. MyControl,
MyItem, and MyCollection are all in the same namespace and, for that
matter, in the same DLL.

In MyControl:

private MyCollection items = new MyCollection();

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(/*...*/)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public MyCollection Items
{
get { return items; }
}

My custom collection editor works, I can add items, and they show up in
the ASPX file as:

<cc1:MyControl id="MyControl1" runat="server">
<Items>
<cc1:MyItem></cc1:MyItem>
</Items>
</cc1:MyControl>

This looks good, everything is persisted. (By the way, MyControl and
MyItem contain other properties that I'm not listing here for the sake
of clarity. Those properties show up, correctly, as attributes of the
respective tags.) But then a wavy red underline appears under Items. The
error message is "The active schema does not support the element items".
Then it becomes unable to display the control in design mode, showing
me an "Error Creating Control" message instead.

From my perspective, it's as though they gave us this tremendous power
to create complex custom controls, and then made them unusable as soon
as they hit the web page canvas. I must be missing something. Any ideas?
I read up on the active schema, but I can't believe I have to build a
whole schema for my class just so I can have a collection property.
 

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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top