Failed to load viewstate

D

David

I am working on project which is written by my former collegue

I got the following exception:
"Failed to load viewstate. The control tree into which viewstate is being
loaded much matech the control tree that was used to save during the
previous request. For example , when adding controls dynamically, the
controls added during a post-back must match poisition of the controls added
during initial request"

This exception is not consistent. Users reported that it happen sometimes
but not all the time.

I know. the page add some control dynamically but I did not have chance to
look at it in detail yet.

Does anybody have any suggestion from where I should start to look?
 
K

Karl Seguin

As you probably know, viewstate restores values based on the IDs of contorls
during postback. In order for this to work, ViewState expects the contorl
tree to be the same before and after. The error basically tells you that
the control tree is got on postback wasn't the same as before. Since you
are using dynamic controls, make sure to give them an explicit ID, and to
make sure htey are recreated on postback with those same IDs.

Since you haven't looked into this yet youhaven't really provided much
detail, hence my general answer.

Karl
 
D

David

Thank you very much for your reply.

I made some changes in the code. Whenever I add a new control I give the
control an ID. Currently it seem like it works. I will keep watching

Thanks
 
E

et

Actually, this gave me a great start, because that was exactly the problem,
it was loading controls incorrectly.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top