Failed to load viewstate in SharePoint Solution

When I tried to upgrade ASP.Net solution to SharePoint solution.I got the following error:

“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”


Solution: The simplest way is to disable “ViewState” for specific control or for the user control as a whole as shown below:

Note : If you need to add a different control on each postback to the same placeholder I advise to make a different placeholder for each different control and each control should be added to a certain placeholder (don’t add different kinds of control to the same placeholder at the same location).

Enjoy 🙂


3 thoughts on “Failed to load viewstate in SharePoint Solution

  1. controlObject.enableViewstate= false
    code line thats showing the error msg…
    controlObject.enableViewstate= true;

    i solved this error in this way when i was adding my controls dynamically…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s