Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > AddParsedSubObject and LoadViewState

Reply
Thread Tools

AddParsedSubObject and LoadViewState

 
 
Michael Combs
Guest
Posts: n/a
 
      05-18-2004
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
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      05-20-2004
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.InnerDefaultProper ty) 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: m...
> 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



 
Reply With Quote
 
 
 
 
Sergey Polyakov
Guest
Posts: n/a
 
      05-24-2004
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.InnerDefaultProper ty) 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: m...
> > 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

>
>



 
Reply With Quote
 
Sergey Polyakov
Guest
Posts: n/a
 
      05-24-2004
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: m...
> 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



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      05-25-2004
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.InnerDefaultProper ty) 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: m...
> > > 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

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AddParsedSubObject breaks after upgrading to VS.NET 2005 RC Steve Franks ASP .Net 2 10-25-2005 06:24 PM
Help needed with AddParsedSubObject() and ControlBuilder() Chris Simeone ASP .Net Building Controls 0 10-29-2004 04:28 PM
Control Builder not parsing attributes in AddParsedSubObject Scot Meyer ASP .Net Web Controls 0 01-15-2004 03:36 PM
LoadViewState works only when datagrid or datalist control not when TextBoxa and other server controls? SSW ASP .Net 2 11-12-2003 03:07 AM
Help w/ LoadViewState and SaveViewState subs Showjumper ASP .Net 0 06-26-2003 01:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57