Hi, Here is a viewstate management issue... The main drawback of the viewstate and its current implementation in the standard server controls are that _all_ the properties of the controls are stored in it. There are two kinds of properties in a webcontrol :
- the "constant" properties : for instance the color of a control, or the thickness of a table border, etc... - the "variable" properties : the content of a cell, a value displayed, ... anything that evolves during the session (data modified by the user or
by a server side treatment). Of course, which property is "constant" and which is "variable" depends on your application (you might have a page where the width of a table border can be modified by the user). Since the standard webcontrols have a huge number
of properties (for a table : cellspacing, borderwidth,... showfooter, background color, etc...), the percentage of variable properties is probably around 0.5%...... Most of the viewstate should not be sent ! It's a terrible waste of bandwidth, isn't it ? So,
I think the solution would be to somehow select the properties we want to store in the viewstate. It is currently possible to disable the state management for a control or even for a whole page, but I would like to store only properties that are really "variable".
The other properties will be set during the page_load. Something like this : page_load (...) { // initialization of the "constant" properties my_control.backgroundcolor = "red"; ... // (most of these properties are actually set with attributes when setting
the control on the aspx page) if (! isPostBack) { // setting a default value for the "variable" properties my_control.text = "0" } else { // retrieving the modified value of the "variable" properties // { get it from viewstate ? } } } If anybody has done something
like this, or has seen an article proposing a "low-level" management of the view state... Any comment or idea is welcome !! Thanks in advance ! Xyboy.
Well, seems like nobody is concerned by this topic ??? I'm still looking for information about viewstate management, and I found two pages of interest : This explains very well when to use viewstate (what properties need it). It seems that viewstate can often
be simply disabled : http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/03/02/CuttingEdge/toc.asp This one explains all the page "lifecycle" (in what order are the events triggered), so you know what to override when writing server controls
: http://www.aspalliance.com/PaulWilson/Articles/?id=6 Bye Xyb.
Note that data is roundtripped with ViewState when the page passes the TrackViewState phase (see Paul's article) and modifications to properties that utilize ViewState are done
after this phase. For example when you set control properties declaratively in aspx, those values are not stored in ViewState (the property can use ViewState but doesn't specify data as "dirty" and therefore doesn't roundtrip it), because setting properties
of controls based on declarative syntax happens before TrackViewState is called. If you change properties in code, then case is different but rule of page phase still applies. Check this thread for more details: 148004
xyboy
Member
62 Points
16 Posts
Low-level management of the viewstate - selecting its content ?
Aug 06, 2003 07:39 AM|LINK
xyboy
Member
62 Points
16 Posts
Re: Low-level management of the viewstate - selecting its content ?
Aug 08, 2003 01:50 PM|LINK
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: Low-level management of the viewstate - selecting its content ?
Aug 11, 2003 08:47 AM|LINK
Teemu Keiski
Finland, EU