viewstate problem

R

Ralph Soons

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 httpSessionState1
to httpSessionState) results in the error as mentioned below.
protected override object LoadPageStateFromPersistenceMedium()
{
1: object httpSessionState1 = this.Session["ViewState"];
2: object httpSessionState = base.LoadPageStateFromPersistenceMedium();

return httpSessionState;
}



protected override void SavePageStateToPersistenceMedium(object viewState)
{
3: this.Session["ViewState"] = viewState;
4: base.SavePageStateToPersistenceMedium(viewState);
}

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

- httpSessionState1 {System.Web.UI.Triplet} System.Object
- [System.Web.UI.Triplet] {System.Web.UI.Triplet} System.Web.UI.Triplet
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.Collections.ArrayList] {Count=3} System.Collections.ArrayList
[0] "M2WWebListBarCtrl1:InformationSelectionBars" string
[1] "EDHNavigationTree1:UltraWebTree1" string
[2] "EDHDataPlaceHolder1:_ctl0:UltraChart1" string


- httpSessionState {System.Web.UI.Triplet} System.Object
- [System.Web.UI.Triplet] {System.Web.UI.Triplet} System.Web.UI.Triplet
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.Collections.ArrayList] {Count=2} System.Collections.ArrayList
[0] "M2WWebListBarCtrl1:InformationSelectionBars" string
[1] "EDHNavigationTree1:UltraWebTree1" 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:productGraphChart' 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.HttpException: An error has occurred because a
control with auto-generated id '_ctl0:productGraphChart' 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:productGraphChart' 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.Page.ProcessPostData(NameValueCollection postData, Boolean
fBeforeLoad)
System.Web.UI.Page.ProcessRequestMain()
 
T

Teemu Keiski

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 LoadPageStateFromPersistenceMedium() {
return Session["ViewState"];
}

protected override void SavePageStateToPersistenceMedium(object viewState)
{
Session["ViewState"] = viewState;
// Bug requires Hidden Form Field __VIEWSTATE
RegisterHiddenField("__VIEWSTATE", "");
}

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


Ralph Soons said:
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
httpSessionState1
to httpSessionState) results in the error as mentioned below.
protected override object LoadPageStateFromPersistenceMedium()
{
1: object httpSessionState1 = this.Session["ViewState"];
2: object httpSessionState = base.LoadPageStateFromPersistenceMedium();

return httpSessionState;
}



protected override void SavePageStateToPersistenceMedium(object
viewState)
{
3: this.Session["ViewState"] = viewState;
4: base.SavePageStateToPersistenceMedium(viewState);
}

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

- httpSessionState1 {System.Web.UI.Triplet} System.Object
- [System.Web.UI.Triplet] {System.Web.UI.Triplet} System.Web.UI.Triplet
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.Collections.ArrayList] {Count=3} System.Collections.ArrayList
[0] "M2WWebListBarCtrl1:InformationSelectionBars" string
[1] "EDHNavigationTree1:UltraWebTree1" string
[2] "EDHDataPlaceHolder1:_ctl0:UltraChart1" string


- httpSessionState {System.Web.UI.Triplet} System.Object
- [System.Web.UI.Triplet] {System.Web.UI.Triplet} System.Web.UI.Triplet
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.Collections.ArrayList] {Count=2} System.Collections.ArrayList
[0] "M2WWebListBarCtrl1:InformationSelectionBars" string
[1] "EDHNavigationTree1:UltraWebTree1" 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:productGraphChart' 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.HttpException: An error has occurred
because a
control with auto-generated id '_ctl0:productGraphChart' 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:productGraphChart' 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.Page.ProcessPostData(NameValueCollection postData,
Boolean
fBeforeLoad)
System.Web.UI.Page.ProcessRequestMain()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top