views:

590

answers:

2

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?

A: 

Are you changing the control tree with some advanced information? Typically on the postback you'll rebuild the same control tree before the event handlers for buttons fire (view state should validate at this point) and then handle the event - which may include clearing out previous parts of the control tree.

benjynito
The control tree changes at multiple points throughout the lifecycle.
Rex M
http://www.15seconds.com/issue/020102.htmI guess I was wondering if you were maybe responding to an event before '6. Process Client-Side PostBack Event' that was causing the view state not to validate. Hope its a step in the right direction, good luck.
benjynito
+1  A: 

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

Chris Ballance