The Active Network
ActiveWin Anonymous | Create a User | Reviews | News | Forums | Advertise | VBA in Excel | Users Online: 0  
 

neowin.net

Amazon.com

  *  

  Understanding ASP.NET View State
Time: 00:00 EST/05:00 GMT | News Source: ActiveWin.com | Posted By: Robert Stein

Microsoft® ASP.NET view state, in a nutshell, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks. In my experiences as a trainer and consultant, view state has caused the most confusion among ASP.NET developers. When creating custom server controls or doing more advanced page techniques, not having a solid grasp of what view state is and how it works can come back to bite you. Web designers who are focused on creating low-bandwidth, streamlined pages oftentimes find themselves frustrated with view state, as well. The view state of a page is, by default, placed in a hidden form field named __VIEWSTATE. This hidden form field can easily get very large, on the order of tens of kilobytes. Not only does the __VIEWSTATE form field cause slower downloads, but, whenever the user posts back the Web page, the contents of this hidden form field must be posted back in the HTTP request, thereby lengthening the request time, as well.

Read Only Comments
Return to News
  Displaying Comments 1 through 2 of 2
  This is an archived static copy of ActiveWin.com.
#1 By 2332 (65.221.182.2) at Friday, June 11, 2004 10:08:31 AM
I second that.

#2 By 20 (24.173.210.58) at Friday, June 11, 2004 07:19:47 PM
Tip: When building tables through code in your CreateChildControls() method, (I have a nifty QuickTable.cs class for easily building code-only HTML tables, let me know if you want it free), add all your controls to the table and add the table to the Control collection as the last thing. ViewState only get's appplied if you're adding a control to a control that is in the main control collection.

For example, if you add a hyperlink control to a table cell that's part of a table that's already been added to the main control hierarchy, the textbox's viewstate will get added to the page's viewstate (which you probably don't want to happen because you usually don't want viewstate on tabel cells and other hard-coded read-only controls).

But if you build up the table first, then, as your final act, add the table to the control hierarchy, no viewstate is saved for any of those controls, including the table and thus you cut about 100K of viewstate cruft :)

server-side tables == major viewstate size



 

  *  
  *   *
 
replica watches