| | |
lifetime of viewstate
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Viewstate "lives" in a hidden variable embedded within the form. Thus, it is resident client-side. While the user is looking at the page, the ASP.NET application isn't "running". Thus, Viewstate doesn't exist at all.
When the users posts the form, IIS/ASP.NET go through a series of steps, one of them being the re-building of the state-bag (ViewState) from the HTTP Request object (remember, Viewstate is a hidden form variable, so is posted in the Request).
The Page Life-Cycle goes on, eventually calling any event handlers, and building the Response. This includes re-packaging the NEW Viewstate into the hidden variable. The Response is shipped back to the client, and your application goes back into non-existence until the user posts again.
Thus, ViewState only "lives" as long as it takes your application to generate a Response.
When the users posts the form, IIS/ASP.NET go through a series of steps, one of them being the re-building of the state-bag (ViewState) from the HTTP Request object (remember, Viewstate is a hidden form variable, so is posted in the Request).
The Page Life-Cycle goes on, eventually calling any event handlers, and building the Response. This includes re-packaging the NEW Viewstate into the hidden variable. The Response is shipped back to the client, and your application goes back into non-existence until the user posts again.
Thus, ViewState only "lives" as long as it takes your application to generate a Response.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Also... Viewstate does not store the "vaules of... controls". The HTTP Request mechanism does that.
Well, that's almost right. Let's say that Viewstate does not store the value of Form Elements. What it does is store the "state" of any controls that have had their attributes altered server-side. For example say you use an ASP.NET Label control, with an initial setting. In response to some event, you change the value of that Label. The Viewstate mechanism would be used to transport that new value to the client.
Well, that's almost right. Let's say that Viewstate does not store the value of Form Elements. What it does is store the "state" of any controls that have had their attributes altered server-side. For example say you use an ASP.NET Label control, with an initial setting. In response to some event, you change the value of that Label. The Viewstate mechanism would be used to transport that new value to the client.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Because Viewstate is scoped to that particular "instance" of that particular page. It has no relevance whatsoever to another page within that application. If you need to maintain some value across the application, you'd use the Session object instead.
I explain ViewState here: http://www.tgreer.com/aspnet_html_02.html
I explore ViewState, Session, the ASP.NET Page Life Cycle, and conditional dynamic controls in this article: http://www.tgreer.com/aspnet_html_04.html
I explain ViewState here: http://www.tgreer.com/aspnet_html_02.html
I explore ViewState, Session, the ASP.NET Page Life Cycle, and conditional dynamic controls in this article: http://www.tgreer.com/aspnet_html_04.html
![]() |
Similar Threads
- $4.99 PR5 lifetime permanent link for sale (Ad Space for Sale)
- Free link Inclusion or 2 USD lifetime link (Relevant Link Exchanges)
- Lifetime ads from $12.50! (Ad Space for Sale)
- $5 lifetime 468x60 banner space (Ad Space for Sale)
Other Threads in the ASP.NET Forum
- Previous Thread: Problem With database Connectivity
- Next Thread: What is the best book to start with ASP.NET
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash form formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers




What is the lifetime of values within the viewstate. 

