Failed to load viewstate on simple control
Hi,
I have an TreeView Control on a user control with a simple onClick event on the tree view that fires and does nothing. However, when I click a node in a tree I get the error message below.
I have tried disabling the view state for the treeview and that doesn't work. ASP.NET 4.0 uses indexes to register controls viewstate. Is there a way to force asp.net to use control ids ? I believe this would fix it. Any help would be appreciated.
How to repeat the issue :
1. Add Treeview to user control. Add OnClick event to tree view.
2. Register User Control into SiteFinity
3. Drag widget to SiteFinity page
4. Click a tree node.
Thanks in advance,
Jon
Server Error in '/TestProject3' 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) +566
System.Web.UI.Control.AddedControl(Control control, Int32 index) +711
Telerik.Sitefinity.Modules.Pages.DraftProxyBase.CreateChildControls(Page page) +1832
Telerik.Sitefinity.Modules.Pages.PageDraftProxy.CreateChildControls(Page page) +25
Telerik.Sitefinity.Web.PageEditorRouteHandler.ApplyLayoutsAndControls(Page page, RequestContext requestContext) +336
Telerik.Sitefinity.Web.RouteHandler.InitializeContent(Page handler, RequestContext requestContext) +476
System.Web.UI.Control.LoadRecursive() +95
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2760
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Hi Jon,
The idea of the edit mode is to be able to add, remove or edit settings of the controls, widgets or the layout in the page. When you add a widget on the page during edit mode , an ajax request is made to the server to get the widget HTML and then the result is added to the page. That's why the widget and it's controls are not represented in the view state of the page and you receive this error when you trigger the postback event. We know this issue and we are going to prevent the clicking on widget's content during the edit mode of the page.
Kind regards,
Teodor
the Telerik team
I had this same problem today and found a work around that works for my case - maybe yours too.
There is a related thread here:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/no-viewstate.aspx
In my case, my pages use a Master Page file as a template (I'm migrating existing design from SF 3.7 and not using layout controls at all).
Enabling ViewState on my master page fixed this issue for me.
<%@ Master Language="C#" EnableViewState="true" %>
Hope this helps some until a fix is released.