Inherit ListItem?

Discussion in 'ASP .Net Building Controls' started by Samuel, Mar 28, 2007.

  1. Samuel

    Samuel Guest

    Hi,

    I am interested in creating a ListItem like control that has the ability to
    persist its AttributeCollection in ViewState, in addition to the Text and
    Value properties.

    However, ListItem is not Inheritable, so what am I do to create such control?

    How does ListItemControlBuilder work? I couldn't find information regarding
    this control on the MSDN site.
     
    Samuel, Mar 28, 2007
    #1
    1. Advertisements

  2. Hi Samuel,

    From your description, you're going to develop a custom ListControl that
    will contains collection of the ListItem like item objects, and also want
    to customize the ListItem so as to add additional properties, correct?

    Based on my research, you can consider the following approach for creating
    such a custom list control:

    **Since ListItem and ListItemCollection classes are sealed that can not be
    override and customize, you may need to create two new classes which
    duplicate these two classes' code and add your custom codelogic (such as
    add additional attributes).

    ** For the custom ListItem and ListItemCollection type, you can use
    reflector to inspect the built-in ListItem and ListItemCollection class.
    You can find that the most important thing to do is inherit the
    "IStateManager". here is the built-in ListItem class's signature:

    ==============
    public sealed class ListItem : IStateManager, IParserAccessor,
    IAttributeAccessor
    {
    ==============

    this interface is used for processing viewstate.

    ** After you've created your custom ListItem and ListItemCollecction types,
    you can use them in your ListControl. Here is a custom list control sample
    from code project site, you can have a look for reference:

    #Custom ComboBox server control for ASP.NET
    http://www.codeproject.com/aspnet/CustomComboBox.asp?df=100&forumid=171101&e
    xp=0&select=1786106

    If there is anything unclear or any other questions on this, please feel
    free to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Mar 28, 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.