Alessandro Zifiglio

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

All posts have moved to Typps

See you there.

Alessandro

Comments

efdee said:

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

# January 4, 2008 11:26 AM

Wayne Hawkins said:

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.

# January 12, 2008 1:07 AM

Erik said:

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...)

:-)

# February 10, 2008 5:27 PM

Flavio Spagnuolo said:

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.

# February 19, 2008 4:26 PM

Jay w said:

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)

# February 29, 2008 8:16 PM

Henry R said:

Excellent article, very useful. Thanks a lot.

# July 10, 2008 4:32 PM

L.Holota said:

nice, helped at the right moment :)

# July 31, 2008 9:33 AM

Sephiroth said:

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.

# September 17, 2008 11:46 AM

ivan said:

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!

# October 29, 2008 5:28 AM

Brian Thomas said:

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.

# November 20, 2008 11:48 AM

Beska Miltar said:

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...

# December 10, 2008 2:15 PM

Merly said:

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

# January 27, 2009 9:26 PM

easanka said:

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..

# February 16, 2009 5:13 AM

Mohammad Insairar said:

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.

# May 31, 2009 2:48 AM

Ron Bars said:

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

# October 29, 2009 5:21 PM

Leo said:

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?

# April 1, 2010 4:51 PM

Intern said:

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

# April 19, 2010 7:48 AM