Viewstate reading caused by ASP. NET Dynamic Control Creation

Source: Internet
Author: User
Tags stack trace
ASP. net controls encountered a depressing problem, the page has a view switch function to achieve, you can choose to use chart or grid to view data, including Grid only, chart Only, grid with chart, and other la S. At the beginning, we found that when switching from grid at bottom to grid at right, the view State of the chart is always null, and the following error occurs when the grid only to grid at right is implemented.

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, 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

The error information is also detailed. You can see the cause of the error at a glance, but you did not expect such a requirement on Web controls.

The problem has been solved, but I will not post it for the time being. I hope to hear your comments.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.