locked
Failed to load viewstate RRS feed

  • Question

  • User-853298616 posted

     Hello.

    This may look like a problem not specific to Dynamic Data but the thing is it only happens in some of the pages and not others, and they're basically built the same way. It happens when I'm in the Edit page of an entity and click "Cancel".

    Here's the error:

     

    Server Error in '/integrationUTL' Application.
    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.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: 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.
    
    Source Error:
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace:
    
    [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) +306
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
       System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
       System.Web.UI.Page.LoadAllState() +312
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1642
    
    
    Version Information: Microsoft .NET Framework Version:2.0.50727.3031; ASP.NET Version:2.0.50727.3031 
      Thanks in advance to anyone capable of deciphering it.
    Tuesday, November 25, 2008 7:55 PM

Answers

  • User1641955678 posted

    Are these Page Templates or custom pages?  Do they do anythign significantly different from the default pages?  These view state errors can often be solved by moving some code from Page_Load to Page_Init.  e.g. if you use a field generator, make sure you do that in Init.

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 12:34 AM

All replies

  • User-710964228 posted

     Check out the property EnableViewState and EnableEventValidation from page directive of ur page and remove these properties

     This might help u to solve your problem

    Tuesday, November 25, 2008 11:37 PM
  • User1641955678 posted

    Are these Page Templates or custom pages?  Do they do anythign significantly different from the default pages?  These view state errors can often be solved by moving some code from Page_Load to Page_Init.  e.g. if you use a field generator, make sure you do that in Init.

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 12:34 AM
  • User-853298616 posted

     Changed the field generator I was using from the Page_Load to Page_Init, and it's now working properly. Thanks!

    Wednesday, November 26, 2008 7:06 PM