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).