Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Moving controls, viewstate problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ujjc001 - 05 Oct 2007 22:07 GMT
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-
tomisarobot@gmail.com - 05 Oct 2007 22:45 GMT
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.
Mark Rae [MVP] - 05 Oct 2007 23:40 GMT
> ViewState is set during Init

ViewState is set during Load:
http://msdn2.microsoft.com/en-us/library/ms178472(vs.80).aspx

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

jdlwright@gmail.com - 05 Oct 2007 23:25 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.