views:

20

answers:

1

In my web.config I have the following:

<pages theme="myTheme" enableSessionState="true" validateRequest="false" 
enableEventValidation="false" viewStateEncryptionMode="Never" 
enableViewStateMac="false">

As soon as I added the theme property I instantly started to receive:

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.

When I remove the theme, I no longer get viewstate errors. Can anyone offer inside to what is happening or how to fix it?

Thanks.

A: 

Fixed by:

  1. Adding runat="server" and ID attributes to link (stylesheet)
  2. Calling Page.Header.FindControl("link").DataBind() in Page_Load method of master page.

Do not call Page.Header.DataBind(); since it will databind the entire header.

subt13