AddParsedSubObject and LoadViewState

Discussion in 'ASP .Net Building Controls' started by Michael Combs, May 18, 2004.

  1. I am building a combobox webcontrol which works from a collection of
    ListItems similar to a standard DropDownList. It uses
    AddparsedSubObject to load the nested ListItem objects (below).

    <cc1:combobox id="ComboBox1" runat="server">
    <cc1:ListItem Text="test1" Value="1"
    Selected="False"></cc1:ListItem>
    <cc1:ListItem Text="test2" Value="2"
    Selected="False"></cc1:ListItem>
    </cc1:combobox>

    I am also overriding Load and Save viewstate to maintain the listitems
    in the viewstate. AddParsedSubObject is always called, in which the
    nested ListItems are loaded into my item list. Then in LoadViewState,
    I'm clearing my item list and loading the list items from the
    viewstate. Is this the correct method for handling this situation?

    Thanks,
    Michael Combs
    Michael Combs, May 18, 2004
    #1
    1. Advertising

  2. Michael Combs

    Teemu Keiski Guest

    Hi,

    wouldn't it be easier to map the ListItems to the Items property (as it
    happens with DDL), when you wouldn't need to deal with AddParsedSubObject as
    this mapping happens automatically when control has ParseChildren(true),
    PersistChildren(false) attributes applied (that is, it inherits from
    WebControl). These attributes have impact that content between control's
    tags need to map to the property or properties of the control.

    DropDownList has Items property declared with
    PersistenceMode(PersistenceMode.InnerDefaultProperty) so that all items
    between begin and end tag must map to the Items property.

    And about ViewState, if you add these ListItems to the Items on every
    request (as happens with AddParsedSubObject), adding them to the ViewState
    is overhead.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Michael Combs" <> wrote in message
    news:...
    > I am building a combobox webcontrol which works from a collection of
    > ListItems similar to a standard DropDownList. It uses
    > AddparsedSubObject to load the nested ListItem objects (below).
    >
    > <cc1:combobox id="ComboBox1" runat="server">
    > <cc1:ListItem Text="test1" Value="1"
    > Selected="False"></cc1:ListItem>
    > <cc1:ListItem Text="test2" Value="2"
    > Selected="False"></cc1:ListItem>
    > </cc1:combobox>
    >
    > I am also overriding Load and Save viewstate to maintain the listitems
    > in the viewstate. AddParsedSubObject is always called, in which the
    > nested ListItems are loaded into my item list. Then in LoadViewState,
    > I'm clearing my item list and loading the list items from the
    > viewstate. Is this the correct method for handling this situation?
    >
    > Thanks,
    > Michael Combs
    Teemu Keiski, May 20, 2004
    #2
    1. Advertising

  3. Hi Teemu,

    > And about ViewState, if you add these ListItems to the Items on every
    > request (as happens with AddParsedSubObject), adding them to the ViewState
    > is overhead.


    It's not overhead if you want to change the item collection dynamically at
    run-time.

    Sergey

    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > wouldn't it be easier to map the ListItems to the Items property (as it
    > happens with DDL), when you wouldn't need to deal with AddParsedSubObject

    as
    > this mapping happens automatically when control has ParseChildren(true),
    > PersistChildren(false) attributes applied (that is, it inherits from
    > WebControl). These attributes have impact that content between control's
    > tags need to map to the property or properties of the control.
    >
    > DropDownList has Items property declared with
    > PersistenceMode(PersistenceMode.InnerDefaultProperty) so that all items
    > between begin and end tag must map to the Items property.
    >
    > And about ViewState, if you add these ListItems to the Items on every
    > request (as happens with AddParsedSubObject), adding them to the ViewState
    > is overhead.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    > http://blogs.aspadvice.com/joteke
    >
    >
    > "Michael Combs" <> wrote in message
    > news:...
    > > I am building a combobox webcontrol which works from a collection of
    > > ListItems similar to a standard DropDownList. It uses
    > > AddparsedSubObject to load the nested ListItem objects (below).
    > >
    > > <cc1:combobox id="ComboBox1" runat="server">
    > > <cc1:ListItem Text="test1" Value="1"
    > > Selected="False"></cc1:ListItem>
    > > <cc1:ListItem Text="test2" Value="2"
    > > Selected="False"></cc1:ListItem>
    > > </cc1:combobox>
    > >
    > > I am also overriding Load and Save viewstate to maintain the listitems
    > > in the viewstate. AddParsedSubObject is always called, in which the
    > > nested ListItems are loaded into my item list. Then in LoadViewState,
    > > I'm clearing my item list and loading the list items from the
    > > viewstate. Is this the correct method for handling this situation?
    > >
    > > Thanks,
    > > Michael Combs

    >
    >
    Sergey Polyakov, May 24, 2004
    #3
  4. Hello Michael,

    If the approach suggested by Teemu Keiski is not appropriate for some
    reason, the way you handling the item list is quite correct

    Sergey

    "Michael Combs" <> wrote in message
    news:...
    > I am building a combobox webcontrol which works from a collection of
    > ListItems similar to a standard DropDownList. It uses
    > AddparsedSubObject to load the nested ListItem objects (below).
    >
    > <cc1:combobox id="ComboBox1" runat="server">
    > <cc1:ListItem Text="test1" Value="1"
    > Selected="False"></cc1:ListItem>
    > <cc1:ListItem Text="test2" Value="2"
    > Selected="False"></cc1:ListItem>
    > </cc1:combobox>
    >
    > I am also overriding Load and Save viewstate to maintain the listitems
    > in the viewstate. AddParsedSubObject is always called, in which the
    > nested ListItems are loaded into my item list. Then in LoadViewState,
    > I'm clearing my item list and loading the list items from the
    > viewstate. Is this the correct method for handling this situation?
    >
    > Thanks,
    > Michael Combs
    Sergey Polyakov, May 24, 2004
    #4
  5. Michael Combs

    Teemu Keiski Guest

    Yeah, that is true. I just didn't get that impression. ;-)

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Sergey Polyakov" <> wrote in message
    news:...
    > Hi Teemu,
    >
    > > And about ViewState, if you add these ListItems to the Items on every
    > > request (as happens with AddParsedSubObject), adding them to the

    ViewState
    > > is overhead.

    >
    > It's not overhead if you want to change the item collection dynamically at
    > run-time.
    >
    > Sergey
    >
    > "Teemu Keiski" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > wouldn't it be easier to map the ListItems to the Items property (as it
    > > happens with DDL), when you wouldn't need to deal with

    AddParsedSubObject
    > as
    > > this mapping happens automatically when control has ParseChildren(true),
    > > PersistChildren(false) attributes applied (that is, it inherits from
    > > WebControl). These attributes have impact that content between control's
    > > tags need to map to the property or properties of the control.
    > >
    > > DropDownList has Items property declared with
    > > PersistenceMode(PersistenceMode.InnerDefaultProperty) so that all items
    > > between begin and end tag must map to the Items property.
    > >
    > > And about ViewState, if you add these ListItems to the Items on every
    > > request (as happens with AddParsedSubObject), adding them to the

    ViewState
    > > is overhead.
    > >
    > > --
    > > Teemu Keiski
    > > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > http://blogs.aspadvice.com/joteke
    > >
    > >
    > > "Michael Combs" <> wrote in message
    > > news:...
    > > > I am building a combobox webcontrol which works from a collection of
    > > > ListItems similar to a standard DropDownList. It uses
    > > > AddparsedSubObject to load the nested ListItem objects (below).
    > > >
    > > > <cc1:combobox id="ComboBox1" runat="server">
    > > > <cc1:ListItem Text="test1" Value="1"
    > > > Selected="False"></cc1:ListItem>
    > > > <cc1:ListItem Text="test2" Value="2"
    > > > Selected="False"></cc1:ListItem>
    > > > </cc1:combobox>
    > > >
    > > > I am also overriding Load and Save viewstate to maintain the listitems
    > > > in the viewstate. AddParsedSubObject is always called, in which the
    > > > nested ListItems are loaded into my item list. Then in LoadViewState,
    > > > I'm clearing my item list and loading the list items from the
    > > > viewstate. Is this the correct method for handling this situation?
    > > >
    > > > Thanks,
    > > > Michael Combs

    > >
    > >

    >
    >
    Teemu Keiski, May 25, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper
    Replies:
    0
    Views:
    4,368
    Showjumper
    Jun 26, 2003
  2. SSW
    Replies:
    2
    Views:
    525
  3. Steve Franks
    Replies:
    2
    Views:
    453
    Steve Franks
    Oct 25, 2005
  4. Chris Simeone

    Help needed with AddParsedSubObject() and ControlBuilder()

    Chris Simeone, Oct 29, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    123
    Chris Simeone
    Oct 29, 2004
  5. Scot Meyer

    Control Builder not parsing attributes in AddParsedSubObject

    Scot Meyer, Jan 15, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    201
    Scot Meyer
    Jan 15, 2004
Loading...

Share This Page