ASP.NET 动态创建控件引起的ViewState读取问题
2005-03-02 15:39
696 查看
今天在开发ASP.NET上的控件时遇到了一个郁闷的问题,页面上有一个View Switch的功能要实现,可以选择使用Chart或是Grid来查看数据,包含了Grid Only, Chart Only, Grid with Chart等几种布局。开始的时候发现由Grid at Bottom到Grid at Right切换的时候,Chart的View State始终是null,后来实现Grid only到Grid at Right时,出现了以下的错误。
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.
Stack Trace:
出错信息倒也详细,一看就知道出错原因,可是没想到Web Controls上还有这样的要求。
问题已经解决,但暂时不贴上来了,希望能听听大家的意见。
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.
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) +189 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +414 System.Web.UI.Control.AddedControl(Control control, Int32 index) +291 System.Web.UI.ControlCollection.Add(Control child) +153 USoft.Aurora.WebControls.AnalysisReport.CreateChildControls() in e:\project\aurora\code.v6\aurora\analysiswebcontrols\analysisreport.cs:172 System.Web.UI.Control.EnsureChildControls() +100 System.Web.UI.Control.PreRenderRecursiveInternal() +38 System.Web.UI.Control.PreRenderRecursiveInternal() +125 System.Web.UI.Control.PreRenderRecursiveInternal() +125 System.Web.UI.Page.ProcessRequestMain() +1499 |
问题已经解决,但暂时不贴上来了,希望能听听大家的意见。
相关文章推荐
- ASP.NET AJAX Advance Tips & Tricks (2) 动态创建Rating控件不能保存ViewState的解决方案
- ASP.NET AJAX Advance Tips & Tricks (2) 动态创建Rating控件不能保存ViewState的解决方案
- 在Asp.net Ajax中动态创建TabPanel控件中碰到的一个问题
- 总结Asp.net中Page加载PostData的具体过程 进而解决"获取动态创建的控件的PostData数据"问题
- asp.net page中用ViewState读取用户控件中的属性
- 总结Asp.net中Page加载PostData的具体过程 进而解决"获取动态创建的控件的PostData数据"问题
- 总结Asp.net中Page加载PostData的具体过程 进而解决"获取动态创建的控件的PostData数据"问题
- ASP.NET - 动态用户控件,ViewState及事件
- ASP.NET 2.0 动态创建控件问题
- 基于ASP.NET的Web动态控件创建
- 动态创建asp.net控件之我见
- ASP.NET 服务器控件的ViewState
- 关于asp.net ide中无法创建控件的问题
- Asp.net中Detailview的控件问题
- Asp.net 动态创建的控件并添加事件,无响应的解决方法。
- asp.net 2.0的TextBox遭遇ReadOnly=True时ViewState不回传的问题
- ASP.NET控件学习笔记之ViewState
- 解决VisualStudio2008下asp.net mvc开发向View中添加服务器控件崩溃的问题
- 如何动态创建asp.net 用户控件
- 解决VisualStudio2008下asp.net mvc开发向View中添加服务器控件崩溃的问题