Failed to load viewstate error

  • Thread starter Thread starter Eamonn O'Connell
  • Start date Start date
E

Eamonn O'Connell

Hi,

We have an ASP.net application, where we dynamically add controls, in the
Page_Load. Occasionally, when the user posts back the page (e.g. clicks Save
button on the page), we get a "Failed to load viewstate" error. This happens
on Windows Server 2003. It happens erratically, and appears to happen after
the application has been running (and in use) for some time. When the
problem arises, it appears to happen more frequently for a while, then
everything works perfectly for another long period...and so on.



We have not been able to re-produce the error on an XP pc yet (so not sure
if it is OS dependant, or some other issue).



The dynamically-added controls are always added in the same order, in the
Page_Load.



Any suggestions would be much appreciated.



Regards,

Eamonn.
 
Hi Eamonn,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're getting a "Failed to load
viewstate" error occasionally. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this error might occur when you have some 3rd-party
control on the ASP.NET page. So could you let me know what version of
ASP.NET you're using and what control you're adding dynamically?

Thanks.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

Yes, we are getting a "Failed to load viewstate" error occasionally.
The exact error is as follows:

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.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at OC_WebControls.TocControlContainer.CreateControls(ResourceManager
LocRM, WebControlFactory ControlFactory, DataRow[] Rows, Hashtable
htParentControls)
at Jupiter.RunTimeForm.ConstructFormView(DataSet dsScreenDefinition)
at Jupiter.RunTimeForm.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()

There are many controls on the form, mostly dot net controls including
textboxes, labelse, checkboxes, htmlimage, hidden field, combo, etc...but
also UltraWebGrig and UltraWebTab from Infragistics.
The problem is diffiult to reproduce using the debug version of the
application so we havn't pin pointed which control has the problem. (I will
put in a try...catch which throws an error idenitifying the control name and
test a 'Release' version.)

The problem arrises after the site has been used for some time, then
frequently occurrs, then disappears for a long time, only to reappear later.

We are using .Net Framework version 1.1.4322

Any assistance you can provide is appreciated.
Regards,
Eamon.
 
Hi Eamonn,

Thanks for your reply. This error seems to have something to do with the
UltraWebGrid. I have found similar issue using this control and get the
same problem as you do.

To isolate the problem, we can try to remove the 3rd-party control and see
if the problem can be reproed. I would suggest you try to contact the
control vendor to see if there is a workaround. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top