Understanding View State in ASP.NET
page 2 of 9
by Joydip Kanjilal
Feedback
Average Rating: 
Views (Total / Last 10 Days): 136905/ 264

How does ViewState work?

All server controls have a property called ViewState.  If this is enabled, the ViewState for the control is also enabled.  Where and how is ViewState stored?  When the page is first created all controls are serialized to the ViewState, which is rendered as a hidden form field named __ViewState.  This hidden field corresponds to the server side object known as the ViewState.  ViewState for a page is stored as key-value pairs using the System.Web.UI.StateBag object.  When a post back occurs, the page de-serializes the ViewState and recreates all controls.  The ViewState for the controls in a page is stored as base 64 encoded strings in name - value pairs.  When a page is reloaded two methods pertaining to ViewState are called, namely the LoadViewState method and SaveViewState method.  The following is the content of the __ViewState hidden field as generated for a page in my system.

Listing 1

<input type="hidden" name="__VIEWSTATE"
 value="dNrATo45Tm5QzQ7Oz8AblWpxPjE9MMl0Aq765QnCmP2TQ==" />

View Entire Article

User Comments

Title: very good   
Name: hasitha
Date: 2006-12-29 8:08:54 AM
Comment:
u're explaned well.Thank u very much 4 u'r help
Title: i have one question   
Name: Satheesh
Date: 2006-12-27 2:15:56 AM
Comment:
I have two webpages in asp.net.... one page contains a textfield and a button.... i am storing the value entered in the texbox to viewstate... and i want that viewstate value to be accessed the next page's textfield control... i am getting null reference exception.... how to solve this
Title: Fine   
Name: senthil
Date: 2006-11-16 3:41:03 AM
Comment:
its really very good, now only i know how to disable viewstate in application level and machine level.
Title: Good Article   
Name: Sebin
Date: 2006-11-15 1:04:07 AM
Comment:
This is a good article. Try to post more article from JOY
Title: good explanation by joydip   
Name: chrsankar@yahoo.com
Date: 2006-11-03 4:59:55 AM
Comment:
I have also read few other articles of Joydip.He is really excellent.Please share your knowledge
Title: View State   
Name: Rakesh
Date: 2006-10-17 11:00:03 AM
Comment:
Very Useful.
Title: Its Good One   
Name: Prashant Narvekar
Date: 2006-09-23 2:10:45 AM
Comment:
its good one. i really liked it.
Title: View State   
Name: Waqas
Date: 2006-09-20 2:13:38 AM
Comment:
Nice Article! Keep it up.
Title: Understanding ViewState ASP.NET   
Name: Satya
Date: 2006-09-12 11:30:29 PM
Comment:
its really nice, you have explained it very nicely with example. Thanks a lot.
Title: great   
Name: nirwan
Date: 2006-09-08 12:48:29 AM
Comment:
great article
Title: Thank you   
Name: Keroles
Date: 2006-09-07 5:53:44 PM
Comment:
Thank you for this article
Title: viewstate   
Name: Manoj kumar singh(infotek software and system (p) ltd)
Date: 2006-09-07 2:51:21 AM
Comment:
This is an excellent article which would help for all asp.net developer
Title: very nice   
Name: jayasimha
Date: 2006-09-02 2:59:26 AM
Comment:
this article is very nice to understand the view state concept
Title: Coooooooool   
Name: ARauf
Date: 2006-08-31 1:02:04 PM
Comment:
I liked the way the author explained using examples. Nice work buddy..
ARauf from Pakistan
Title: Nice Article   
Name: Rakesh Nandrajog
Date: 2006-08-30 5:38:49 PM
Comment:
Really nice article
Title: View State   
Name: Jason Hunt
Date: 2006-08-30 10:02:59 AM
Comment:
An excellent article. Viewstate is often bloated on new developer's websites. I, myself, presumed I knew enough about it and you and certainly proved me wrong. I'm going to use your information on new development. Thank you for your article and I hope you continue to "educate" the masses.
Title: Superb   
Name: Sana
Date: 2006-08-30 9:30:07 AM
Comment:
Good article. Clearly said.
Title: hmm   
Name: Rah
Date: 2006-08-30 7:44:14 AM
Comment:
Continue with the rest of the articles
Title: More detailed explanation   
Name: rekna
Date: 2006-08-30 6:40:07 AM
Comment:
You can find a more detailed explanation of the viewstate on http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx. It's a long article, but very important to understand the real workings of viewstate, and to avoid some common mistakes!!!
Title: Understanding View State in ASP.NET   
Name: Jitu
Date: 2006-08-30 5:03:45 AM
Comment:
Really good explaination of viewstate. Author has cover almost all areas of viewstate. Best for beginer and confused programmers.
Title: viewstate   
Name: yogesh
Date: 2006-08-25 6:31:28 AM
Comment:
good
Title: Sanjay's View state   
Name: Sanjay Jaiswal
Date: 2006-08-10 6:59:41 AM
Comment:
This topic was little bit confuse d forme...but after rading this......give the whole logic behind the View State.



extremely good enough!!!!
Title: view state in asp.net   
Name: srilatha
Date: 2006-08-02 5:43:34 AM
Comment:
Hai,
The article is very informative. Thanks a lot.
Regards,
srilatha
Title: nice way   
Name: Mahesh Kumar Sharma
Date: 2006-08-01 9:53:36 AM
Comment:
This topic make little confuse me but joydip u done exelent job No body will explain in such deep..like Joydip has explained.. Thanx...
Title: good one   
Name: saurabh
Date: 2006-08-01 6:04:48 AM
Comment:
u have explained it in a very nice way. please carry it on. i am expecting some more topics to be covered from tou.
Title: great n excellent   
Name: Anonymous
Date: 2006-08-01 5:24:37 AM
Comment:
No body will explain in such deep..like Joydip has explained.. Thanx...
Title: asp.net examples   
Name: Farooq Ahmad Salmani
Date: 2006-07-14 8:24:54 AM
Comment:
I want more Examples of asp.net
Title: View State   
Name: Françoise
Date: 2006-07-11 11:55:28 AM
Comment:
This is a very good explanation the the View State concept.

Thank you very much. 07/11/2006
Title: Very Nice   
Name: Koteswara Rao
Date: 2006-07-10 10:28:56 AM
Comment:
Hi,
You have Explained very well about View state in Asp.net. It is most useful for whome Newly started programing in Asp.Net
Title: nice   
Name: venu
Date: 2006-07-08 2:52:59 PM
Comment:
hi, U explained very well.

some more topics we are expecting from U.
Title: view state   
Name: G.srinivas
Date: 2006-07-06 1:55:21 AM
Comment:
hi,
this site is very useful for the individuals who want to improove their subject.i am thankful to them who had prepared it.this site is helped me to know everything about viewstate in asp.net.oncegain thanking u
from,
srinivas.G
Title: View State   
Name: Hadi Alhendi
Date: 2006-07-04 3:10:54 AM
Comment:
I found this article very useful i want to thanks Joydip for this great article
Title: Very Good   
Name: Rajesh Medackel
Date: 2006-07-04 1:07:19 AM
Comment:
That was a very good one......:-)


Rajesh Medackel,India
Title: Do The Best   
Name: Viamlram
Date: 2006-07-04 12:53:58 AM
Comment:
You are explained well.It is derived easy to understand by the beginer.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-09-22 6:14:14 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search