Failed to load viewstate ? Typical problem, with an obvious solution.

All posts have moved to Typps

See you there.

Alessandro

17 Comments

  • I ran into similar problems little over a year back. Would have been nice to have this blog post back then ;)

  • I am getting this error my self. I know for a FACT, that it is not my code. My computer crash and I had to pull the power lead and restart it. After a restart, I am getting this error. So it has to be something to do with Visual Stuiod or IIS system. So boo for Microsoft, this is a fault at there end. I think the solution at this point is start a new project in Visual Stuiod and then move my files over. I bet it will then work.

  • Nice topic, i can follow.
    But what about AJAX - update panel...
    I got the error, no dynamic control loading (on my part).. Its a update panel with a multiview. could it be that the update panel couses a reordering or when the page is loading asp.net "thinks" there are less controls then after the postback (async...)
    :-)

  • Also happens that if you save something in the viewstate before the statebag has been saved but also before your control has been added to the parent´s control collection, it may occur that your values would not be restored after postback. Is happened to me. My solution was to set the viewstate properties after the control was added to the parent´s control collection.

  • This has helped me greatly, as I am using user controls to dynamically generate forms. Disabling the viewstate allowed me to not have to reload the controls during onit (which is good if you want to keep viewstate, but in my case I recreate it anyways)

  • Excellent article, very useful. Thanks a lot.

  • nice, helped at the right moment :)

  • Nice solution. Just the wrong example though. I believe you were looking for the Button and the DropDownList as an example of a ViewState error.

  • I'm a newbie to web programming, thanks for this post I nearly went into programming how to by pass the viewstate problem - after reading first few sentences I't became clear I dont actually need viewstate enabled on user controls that I added dynamically.Thanks a bunch!

  • What are you suppose to do when you receive this error and you haven't added any dynamic controls?

    I have a datalist and in the edit template I have an fckEditor. When I select edit I receive this error. It only works when I remove the editor. I have a similar setup in another web page with no problems.

    I don't know if this means anything but I have to select edit twice before it goes into edit mode.

    Any ideas? Thank you.

  • We're running into this problem and have been for some time. I spent some time looking at the pages that we were seeing this error on, looking for where controls might be added or removed. Nothing like that is happening on the page anywhere. Then, after further investigation, we discovered that clearing "temporary internet files" on the client would fix the problem.

    It looks like the problem can also be tickled by the user having a version of the page cached that doesn't match up exactly with the current version of the page. This is probably happening for us because some items were removed from the viewstate during a release (not removed from the page...just had EnableViewState set to false.)

    Now we just have to figure out what to do about it...

  • Thanks! Setting the EnableViewState = false of the control helps.

  • the artical was really help full in my case.. i got the same error when i press a button in update pannel.thing is i dont have any dynamic controls adding on my page. anyhow by adding the "EnableViewState= fals;" on Page_Load ()my problem was solved.. thank you for everyone..

  • Great Article, thanks alot,
    but what about loading usercontrols dynamically, i had this problem and i couldn't just disable the view state for the loaded controls.
    I had to redirect to the same page again just before loading a new usercontrol, to clear the viewstate from the old control's values.

  • I am glad it answered my question. Enableviewstate is the Answer!

  • So what happen is you need to add different controls depending of the __EVENTARGUMENT?. Lets say that sometimes you need to refresh controls based on one's postback and other times you just need to clean them all and add new ones... How would you handle this scenario?

  • Thanx buddy. It really worked for me. I would have never realized the solution for this otherwise

Comments have been disabled for this content.