By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

Viewstate error on second postback to page

P: n/a
I have a page that uses a custom object I wrote to build a table. I also
have a post back to the page to remove items from that table. When the page
loads I can see the viewstate code on the source of the page is about 5
lines. When I post back to remove an item and rebuild the page it works. I
view the source of the page and the viewstate code has doubled in size even
though I have less data for it to hold. On the second post back I get "The
viewstate is invalid for this page and might be corrupted."

I get this error even if I turn off view state for the table that is being
rebuilt. Any thoughts on what is happening? I can provide more detail if
needed. Also, this code is running locally on my PC. There is no issue
with the transfer between webservers.


Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Chris Thompson" <ch************@whitlockebs.com> wrote in message
news:u2**************@TK2MSFTNGP12.phx.gbl...
I have a page that uses a custom object I wrote to build a table. I also
have a post back to the page to remove items from that table. When the page loads I can see the viewstate code on the source of the page is about 5
lines. When I post back to remove an item and rebuild the page it works. I view the source of the page and the viewstate code has doubled in size even though I have less data for it to hold. On the second post back I get "The viewstate is invalid for this page and might be corrupted."

I get this error even if I turn off view state for the table that is being
rebuilt. Any thoughts on what is happening? I can provide more detail if needed. Also, this code is running locally on my PC. There is no issue
with the transfer between webservers.


Chris, if you turn on page tracing, you'll find that it will show you the
control hierarchy, along with the viewstate size each control is
contributing.

This sort of thing happens when the control hierarchy changes between
postbacks. At the beginning of a subsequent request, you first want to
reconstruct the same control hierarchy which existed at the end of the
previous request. This control hierarchy can then consume the same ViewState
which it created at the end of the previous request. Only then can you
change the control hierarchy by adding or removing controls.

This changed hierarchy can then produce viewstate. At the beginning of the
next request, you'll rebuild the control hierarchy as it was at the end of
this request ...
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #2

P: n/a
Hi,

Thanks for the reply. I'm a little confused on the control hierarchy.
How is it that I can control/change this between requests?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

P: n/a
"Chris Thompson" <ch************@whitlockebs.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
Hi,

Thanks for the reply. I'm a little confused on the control hierarchy.
How is it that I can control/change this between requests?


The term "Control hierarchy" (or better, "Control Tree") refers to which
controls contain which other controls in their "Controls" collection. It can
be changed by doing things like dynamically adding or removing controls.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.