Failed to load viewstate. The control tree into which viewstate...
I ran into a snag today.. I had a form with two text boxes, a dropdownlist and a HTML file control. Each time the form posts back I get this error:
[HttpException (0x80004005): 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.]
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +189
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +414
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +414
System.Web.UI.Page.LoadPageViewState() +306
System.Web.UI.Page.ProcessRequestMain() +423
After some googling, I found out that each time I mess around with creating controls at runtime, the framework can easily get confused about which viewstate belongs to which control after posting back. Comments on this article from Eggheadcafe.com imply that the framework uses indexes not control IDs to restore viewstate.... blah blah. I took of the html server control for now but I'll take care of it later
Last Updated:Thursday, September 02, 2010By:alfero#
with your OpenID.
If you do not know what OpenID is,