473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Viewstate error on second postback to page

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
3 1813
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is setting the selected index on the lists. If someone...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
1
by: Ralph Soons | last post by:
Hi all, I am trying to save the viewstate in a session instead of storing it in a hidden of the webpage which is default. This because of performance reasons. When I use line 2 in combination...
6
by: vinay | last post by:
What is this error?? Exception Details: System.Web.HttpException: Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte buf, Byte modifier, Int32 start, Int32...
11
by: Nad | last post by:
Hello, I have a page with two link buttons. When I click on the first one I call server.execute("target.aspx") to view target.aspx on the original page. Then I click on the second link button...
9
by: Jamie | last post by:
I am receiving an Invalid ViewState error after posting back to the same page twice. Consistently the error occurs after the second postback and not after the first. I have looked into creating...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
3
by: George Thompson | last post by:
Hi, I come from an ASP background, and I am currently working on a .NET project, so please excuse me if this is a dumb question ... I have written a dynamically generated menu that uses the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.