开发者

Failed to load viewstate

I have an aspx page that dynamically loads user controls: there is an UpdatePanel that holds these controls (one each time). When I change a control with another one it fails with the message:

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 application. For example, when adding controls dynamically, the controls added during a return must match the type and position of the controls added during the initial application.

All of three controls inherit from System.Web.UI.UserControl. Maybe I can solve the problem doing:

  1. Load three controls at start time and then hide two of them as we need it.
  2. Use three UpdatePa开发者_开发问答nels, one for each user control.
  3. Any advice?


Make sure that postbacks aren't updating undesired panels by setting the postback mode to conditional and updating them manually.


When you dynamically add the user controls, are you assigning the id property? And are you adding the control again, on postback, setting the id property to the same value?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜