Moving controls, viewstate problem

U

ujjc001

Ok, I know why it happens, but I don't know how to fix it. I've got
code that responds to a user clicking an up or down arrow button which
moves a div layer down or up into a placeholder div layer. That all
works fine, but when the user moves a part up or down, then causes a
postback, I get the viewstate problem.

Failed to load viewstate. The control tree into which viewstate is
being loaded must match the control tree that was used to save
viewstate during the previous request. For example, when adding
controls dynamically, the controls added during a post-back must match
the type and position of the controls added during the initial
request.



How can I take a div and have it switch places and not break
viewstate?
If you want code, let me know-
 
T

tomisarobot

assuming I understand your problem...

ViewState is set during Init, so perhaps override OnInit or PreInit ?

...overload OnInit...
{
//fix
base.OnInit(...
}

perhaps waiting until after init to move your div would work as well.
 
J

jdlwright

How can I take a div and have it switch places and not break
viewstate?

You'll have to call ClearChildViewState, which will also mean that
you'll need to fully recreate the child controls and not rely on
viewstate to fill them in.

Jim
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top