We help IT Professionals succeed at work.

getting " The state information is invalid for this page and might be corrupted." error on saving viewstate into session

Medium Priority
Last Modified: 2012-06-21
I have web page, which has tree update pannles.
and along with that two radio button and 3 image buttons.
in update pannel 1 contains one tree control.
and user select one radio button then clicks on the button to load the tree control.
I have override the two function given below to save viewstate but when i select one radio button and clicks on load tree button i am getting the erro give in the title field.

could any one help me here why i am getting this error.
protected override object LoadPageStateFromPersistenceMedium()
        return Session["ViewState"];
    protected override void SavePageStateToPersistenceMedium(object viewState)
        Session["ViewState"] = viewState;
        // Bug requires Hidden Form Field __VIEWSTATE
        ClientScript.RegisterHiddenField("__VIEWSTATE", "");

Open in new window

Watch Question


I read that article but it did not helped me
The hidden field "__VIEWSTATE" is used to store control's state information and used for the server to restore the control's state information. The server will validate if the data stored in it has been tampered before restoring the state, so if validation fails, the server will throw error and will not restore the control's state information.
Why do you need to change this hidden field which cause the validation to fail?


Hi prairiedog

All I want is so save the state of the page so that when user come back to the page , then he should get  the same setting/view which was there before he leaves the page.

Is there any different way to do this?
There should be many ways to do it depending on your exact requirements. Can you specify what state do you need to save? Can you give more information on the page?


sure prairiedog,
here is all about my web page.

on my web page, I have three update panels. along with that 2 radio buttons and one button which are out side the update panels.
Update panel 1 contains one tree control.
Update panel 2 and 3 contains html table runat server

now user select one radio button and click on the load button to load the tree control.
after tree control is loaded then user select nodes from the tree control and clicks on show node button to view summary information of the selected nodes in update panel`s 2 html table.

lastly user selects one row from update panel 2 to view that article in full details in the update panel 3 html table.

I know html table contents by default doesn't get save in the viewstate so for these i need to write a function.

but some how i save the radio button selection and tree control info and load it back again so that user does not have to do the process again and again.

I hope i am clear, pls let me know for any query
Save the radion button selection and tree control node selection in session variables instead of view state, because the life scope of the view state is only within the page. When user navigates away to a different page, the view state of the previous page is destroyed.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.