views:

40

answers:

2

The following message appears in our log:

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.

Well, that's pretty clear, and alot has been written about this subject. However, I cannot reproduce this behavior, and I only find a couple thousand errors per day in the logs; so it's probably isn't that obvious.

The page in question has an UpdatePanel and loads one of three usercontrols depending on the querystring.

Is there any known issue with some clients, or any other possible explanation?

A: 

One possible Issue could be, that

  • you load Controls dynamically
  • you do not give them explicit an ID
  • the order in recreation of these control is different (GET vs. POST)

I had such an issue once. Also Repeater are good candidates for such a behaviour because each Item is an INamingContainer. If the content of the Repeater changes during Postback you could get that error.

Arthur
A: 

I've seen this behaviour in cases where update panels are on the page and a value somewhere outside of this is changed but never propagated to the client.

The solution is to make sure that any value that gets changed gets updated client side. Thus when the postback occurs all the data matches what is supposed to be there server side.

If you have such data you can put it into an update panel as well.

Set UpdateMode="Conditional" on it and in your codebehind you can just call the update panels .update method when you need to update it.

Middletone