How to give a custom ASP.NET control the ability to parse XML markup to a collection?

Posted by Vilx- on Stack Overflow See other posts from Stack Overflow or by Vilx-
Published on 2010-04-01T12:18:09Z Indexed on 2010/04/01 12:33 UTC
Read the original article Hit count: 241

I'm writing a custom ASP.NET webcontrol and would like it to have a collection of custom items which can also be specified in the XML markup. Something like this:

class MyControl: WebControl
{
    public IList<MyItemType> MyItems { get; private set; }
}

And in the markup:

<asd:MyControl runat="server" id="mc1">
    <MyItems>
        <MyDerivedCustomItem asd="dsa"/>
        <MyOtherDerivedCustomItem asd="dsa"/>
    </MyItems>
</asd:MyControl>

How do I do this? I though this was all about implementing some interface on the collection or adding some special attributes to the property, but nothing I do seems to work.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#