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

Posted on 2009-02-17
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

Question by:ziorrinfotech
    LVL 15

    Expert Comment

    by:Praveen Venu

    Author Comment

    I read that article but it did not helped me
    LVL 22

    Expert Comment

    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?

    Author Comment

    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?
    LVL 22

    Expert Comment

    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?

    Author Comment

    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
    LVL 22

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now