Failed to load View State 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”

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

  • Disable “ViewState for a specific control or
  • Disable “ViewStatefor the whole user control as shown below:

Disable View State in SharePoint

Note:  don’t add different kinds of User Controls to the same placeholder at the same location. it’s recommended to add each User Control at an Indepenedt Placeholder


 

Advertisements

3 thoughts on “Failed to load View State 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…

    Like

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s