Asp – viewstate failing on postback

asp.netviewstate

We have a web content management system (based on Sharepoint 2007/MOSS, but for the purposes of this problem, that is not relevant, so please stick around even if you haven't worked on MOSS!). On a given page, there are conditions we cannot change:

  • An editor clicks "Edit" and the page posts back.
  • When it reloads in edit mode, the control tree is entirely different.
  • ViewState must be enabled in edit mode, since the edit controls post back frequently

If we disable ViewState in presentation mode, everything works fine. ViewState gets set to "enabled" on the edit postback, the ViewState tree is built up for the first time as the edit controls are generated, and all is well.

If we enable ViewState in presentation mode, when transitioning from presentation to edit, we get a ViewState error because the control tree changes.

We need to enable ViewState in presentation mode, so we need to fix this transition error.

We have tried disabling ViewState during the postback, then programmatically posting back again and re-enabling it, but this causes validation issues with MOSS, so it does not appear to be an option.

Ideas?

Best Answer

Have you tried the clear method on the property bag ;-)