473,721 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

viewstate problem

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 with line 4, my application works. Using
Line 1 in combination with line 3 (and of course renaming httpSessionStat e1
to httpSessionStat e) results in the error as mentioned below.
protected override object LoadPageStateFr omPersistenceMe dium()
{
1: object httpSessionStat e1 = this.Session["ViewState"];
2: object httpSessionStat e = base.LoadPageSt ateFromPersiste nceMedium();

return httpSessionStat e;
}

protected override void SavePageStateTo PersistenceMedi um(object viewState)
{
3: this.Session["ViewState"] = viewState;
4: base.SavePageSt ateToPersistenc eMedium(viewSta te);
}

One other strange thing: there's a difference between httpSessionStat e1 and
httpSessionStat e. Comparing the session states in the debugger shows:

- httpSessionStat e1 {System.Web.UI. Triplet} System.Object
- [System.Web.UI.T riplet] {System.Web.UI. Triplet} System.Web.UI.T riplet
System.Object {System.Web.UI. Triplet} System.Object
+ First "187252947" System.Object
+ Second {System.Web.UI. Triplet} System.Object
- Third {Count=3} System.Object
- [System.Collecti ons.ArrayList] {Count=3} System.Collecti ons.ArrayList
[0] "M2WWebListBarC trl1:Informatio nSelectionBars" string
[1] "EDHNavigationT ree1:UltraWebTr ee1" string
[2] "EDHDataPlaceHo lder1:_ctl0:Ult raChart1" string
- httpSessionStat e {System.Web.UI. Triplet} System.Object
- [System.Web.UI.T riplet] {System.Web.UI. Triplet} System.Web.UI.T riplet
System.Object {System.Web.UI. Triplet} System.Object
+ First "187252947" System.Object
+ Second {System.Web.UI. Triplet} System.Object
- Third {Count=2} System.Object
- [System.Collecti ons.ArrayList] {Count=2} System.Collecti ons.ArrayList
[0] "M2WWebListBarC trl1:Informatio nSelectionBars" string
[1] "EDHNavigationT ree1:UltraWebTr ee1" string

Can anybody help me?! Thanks for your help,

Ralph Soons

The following server error occurs:

Server Error in '/EDHWebView' Application.
----------------------------------------------------------------------------
----

An error has occurred because a control with auto-generated id
'_ctl0:ProductG raphChart' could not be located to raise a postback event. To
avoid this error, explicitly set the ID property of controls that raise
postback events.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: An error has occurred because a
control with auto-generated id '_ctl0:ProductG raphChart' could not be
located to raise a postback event. To avoid this error, explicitly set the
ID property of controls that raise postback events.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): An error has occurred because a control with
auto-generated id '_ctl0:ProductG raphChart' could not be located to raise a
postback event. To avoid this error, explicitly set the ID property of
controls that raise postback events.]
System.Web.UI.P age.ProcessPost Data(NameValueC ollection postData, Boolean
fBeforeLoad)
System.Web.UI.P age.ProcessRequ estMain()

Nov 18 '05 #1
1 3751


Hi,

you don't need to call the base class methods when overriding ViewState
persistence methods. Are you callign them just to test the thing? Anyway,
with this approach they should work fine:

protected override object LoadPageStateFr omPersistenceMe dium() {
return Session["ViewState"];
}

protected override void SavePageStateTo PersistenceMedi um(object viewState)
{
Session["ViewState"] = viewState;
// Bug requires Hidden Form Field __VIEWSTATE
RegisterHiddenF ield("__VIEWSTA TE", "");
}

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Ralph Soons" <ralph(ralph)@s oons.demon.nl> wrote in message
news:ex******** ********@TK2MSF TNGP12.phx.gbl. ..
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 with line 4, my application works. Using
Line 1 in combination with line 3 (and of course renaming
httpSessionStat e1
to httpSessionStat e) results in the error as mentioned below.
protected override object LoadPageStateFr omPersistenceMe dium()
{
1: object httpSessionStat e1 = this.Session["ViewState"];
2: object httpSessionStat e = base.LoadPageSt ateFromPersiste nceMedium();

return httpSessionStat e;
}

protected override void SavePageStateTo PersistenceMedi um(object
viewState)
{
3: this.Session["ViewState"] = viewState;
4: base.SavePageSt ateToPersistenc eMedium(viewSta te);
}

One other strange thing: there's a difference between httpSessionStat e1
and
httpSessionStat e. Comparing the session states in the debugger shows:

- httpSessionStat e1 {System.Web.UI. Triplet} System.Object
- [System.Web.UI.T riplet] {System.Web.UI. Triplet} System.Web.UI.T riplet
System.Object {System.Web.UI. Triplet} System.Object
+ First "187252947" System.Object
+ Second {System.Web.UI. Triplet} System.Object
- Third {Count=3} System.Object
- [System.Collecti ons.ArrayList] {Count=3} System.Collecti ons.ArrayList
[0] "M2WWebListBarC trl1:Informatio nSelectionBars" string
[1] "EDHNavigationT ree1:UltraWebTr ee1" string
[2] "EDHDataPlaceHo lder1:_ctl0:Ult raChart1" string
- httpSessionStat e {System.Web.UI. Triplet} System.Object
- [System.Web.UI.T riplet] {System.Web.UI. Triplet} System.Web.UI.T riplet
System.Object {System.Web.UI. Triplet} System.Object
+ First "187252947" System.Object
+ Second {System.Web.UI. Triplet} System.Object
- Third {Count=2} System.Object
- [System.Collecti ons.ArrayList] {Count=2} System.Collecti ons.ArrayList
[0] "M2WWebListBarC trl1:Informatio nSelectionBars" string
[1] "EDHNavigationT ree1:UltraWebTr ee1" string

Can anybody help me?! Thanks for your help,

Ralph Soons

The following server error occurs:

Server Error in '/EDHWebView' Application.
----------------------------------------------------------------------------
----

An error has occurred because a control with auto-generated id
'_ctl0:ProductG raphChart' could not be located to raise a postback event.
To
avoid this error, explicitly set the ID property of controls that raise
postback events.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: An error has occurred
because a
control with auto-generated id '_ctl0:ProductG raphChart' could not be
located to raise a postback event. To avoid this error, explicitly set
the
ID property of controls that raise postback events.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): An error has occurred because a control with
auto-generated id '_ctl0:ProductG raphChart' could not be located to raise
a
postback event. To avoid this error, explicitly set the ID property of
controls that raise postback events.]
System.Web.UI.P age.ProcessPost Data(NameValueC ollection postData,
Boolean
fBeforeLoad)
System.Web.UI.P age.ProcessRequ estMain()

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
21644
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
3
2648
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
2
2822
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We intermittantly get the following exception - EXCEPTION MESSAGE: The viewstate is invalid for this page and might be corrupted. STACK TRACE:
10
2275
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and disable the session state in Web.Config the VIEWSTATE variable is still maintained and stores some values. Can anyone tell what those values are for, i.e what other info is stored in VIEWSTATE other than the session ID and the control values ?
2
1989
by: Janaka | last post by:
We have managed to lock down 99% of the application errors occurring in our asp.net sites. The only errors which occur on a regular basis now are viewstate errors. We have disabled viewstate on the majority of pages but kept them where absolutely necessary, such as shopping carts, adding items, etc. Also we've made sure the following have been met: EnableViewStateMac = false Disabled viewstate on all controls which are unnecessary...
6
2743
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a placholder and the user clicks on a specific control outside of the usercontrol and some Javascript is run where a hidden variable is changed to reflect another usercontrol (usercontrolB).
2
3962
by: epigram | last post by:
I'm responding to a button click event on an asp.net web form. I then need to retrieve the value from a TextBox control and I want to compare it against the control's previous value to see if it has changed. How can I retrieve a control's previous value from the ViewState? I know that I could save the control's previous value in a session variable, reretrieve it's value from the db, etc. But it would appear the control's previous value...
6
2862
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in order for a dynamically created control to persist its state, it needs to be created and loaded into the page control hierarchy before the viewstate is loaded. The proposed solution, and that which I have been using, has been to create all of...
1
7594
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 usercontrol is a button and a label. Everytime the button is clicked a counter which is stored in the viewstate is increased and displayed in the label.
0
2230
by: Scott Roberts | last post by:
I always thought that the viewstate "keys" included the control ID. As long as the control IDs were unique, there shouldn't be any conflicts. Well, it appears that that may not be the case with dynamic controls. Our application was having a problem very similar to the one described here: http://weblogs.asp.net/alessandro/archive/2008/01/04/failed-to-load-viewstate-typical-problem-with-an-obvious-solution.aspx Unfortunately, the "fix"...
0
8837
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9130
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9059
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8005
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6668
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5977
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2129
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.