Can I use the Dictionary type as a (persistet) property of a custom server control?

217 views Asked by At

I'm currently developing a server control which should be configured via a list of key/value pairs, like this:

<MyControls:ContentRenderer ID="ContentRenderer1" runat="server">
    <MyControls:Placeholders>
        <MyControls:Placeholder key="ident1">Some text which replaces {ident1}</MyControls:Placeholder>
        <MyControls:Placeholder key="ident2">Some text which replaces {ident2}</MyControls:Placeholder>
    </MyControls:Placeholders>
<MyControls:ContentRenderer />

I want that property to be a dictionary so I can quickly retrieve placeholder mappings by their identifier. I know how to create a property which is persisted with the above markup by using the List< T > class but I'd like to have a hashmap-like datastructure.

I read a lot of stuff at msdn but I still have no clue what to do if you want full control over the way your control markup is parsed.

1

There are 1 answers

2
Brian Mains On BEST ANSWER

I don't think dictionaries are supported in this way. However, the way this is done, is instead of using List, use a custom list-based class, which also stores a dictionary mapping of the key/object.

HTH.