Custom control collections - IList or ControlCollection

Discussion in 'ASP .Net Building Controls' started by Mark, Apr 27, 2007.

  1. Mark

    Mark Guest

    Dear community,

    I am in the process of designing and writing a custom control that has child
    controls of which I have derived from the Panel WebControl. I am becoming
    confused as to the required implementation of the collection to hold the
    child controls. I have started to implement a Collection class which inherits
    from IList. I have followed roughly the implementation of the frameworks
    ListItemCollection but have now started to become slightly confused about the
    IStateManager implementation. Should I be going down this road or should my
    control collection class just be derived from the ControlCollection class??
     
    Mark, Apr 27, 2007
    #1
    1. Advertisements

  2. Mark

    Mark Guest

    Just to add to my post, I have just been looking at some of the
    System.Web.UI.WebControls implementations for WebControl collections and it
    seems some opt for their collection classes to extend IList and some inherit
    from ControlCollection. I was particularly interested in looking at the
    disassembled MultiView, View and ViewCollection classes as this control seems
    to be close to what my custom control is trying to acheive. Although, when I
    modelled my collection class based on extending ControlCollection I had
    difficulty when trying to cast out my type from a ControlCollection type in
    the Items method.
    What are the rules governing the implementation of custom child control
    collections and managing viewstate? Am I right in thinking that because my
    child controls inherit from existing web controls then I need not to worry
    about viewstate management in the collection? I would be most grateful for
    some advise on this topic.
     
    Mark, Apr 27, 2007
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.