Failed to load viewstate

S

Sanjay Pais

We keep getting this error on one of our web pages. I have absolutely no
idea which control is causing the problem. How do i diagnose and fix this
problem?



It has been driving us nuts!



Thanks



Sanjay



System.Web.HttpException: Failed to load viewstate. The control tree into
which viewstate is being loaded must match the control tree that was used to
save viewstate during the previous request. For example, when adding
controls dynamically, the controls added during a post-back must match the
type and position of the controls added during the initial request.

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)

at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)

at System.Web.UI.Page.LoadAllState()

at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
C

Cowboy \(Gregory A. Beamer\)

Essentially, the framework pulls the viewstate and starts matching controls
to their viewstate values. You might then have new values from the submit,
which overrides these values. Then viewstate is reset.

By design, it fails if it has a value that does not match a control. This is
most common with dynamically added controls. That leads to this question:

Are you using dynamically added controls? If so, you have to place them on
the page before ViewState is pulled by the CLI ... IF they use viewstate on
these controls, that is.
 
B

bruce barker

generally this happens when on postback, controls do not get the same id as
on the original render. this is caused by having server controls with no id
specified (so the id is generated). then postback logic causes the controls
to be created in a different order, so the ids do not match the render ids.

check for <% if %> on the asp page

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top