Welcome Guest Search | Active Topics | Members | Log In | Register

Moving controls, viewstate problem Options · View
ujjc001
Posted: Friday, October 05, 2007 7:07:29 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 07:07:29
Date: Fri, 05 Oct 2007 14:07:29 -0700

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
Posted: Friday, October 05, 2007 7:45:58 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 07:45:58
Date: Fri, 05 Oct 2007 14:45:58 -0700

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.


jdlwright@gmail.com
Posted: Friday, October 05, 2007 8:25:16 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 08:25:16
Date: Fri, 05 Oct 2007 15:25:16 -0700


> 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


Mark Rae [MVP]
Posted: Saturday, October 06, 2007 12:40:01 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 00:40:01
Date: Fri, 5 Oct 2007 23:40:01 +0100

<tomisarobot@gmail.com> wrote in message
news:1191620758.476209.132290@19g2000hsx.googlegroups.com...

> ViewState is set during Init

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


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

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.129 seconds.