469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

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 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(NameValueCollec tion postData, Boolean
fBeforeLoad)
System.Web.UI.Page.ProcessRequestMain()

Nov 18 '05 #1
1 3481


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" <ralph(ralph)@soons.demon.nl> wrote in message
news:ex****************@TK2MSFTNGP12.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
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(NameValueCollec tion postData,
Boolean
fBeforeLoad)
System.Web.UI.Page.ProcessRequestMain()

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by John Kirksey | last post: by
3 posts views Thread by Steve Drake | last post: by
10 posts views Thread by neo | last post: by
2 posts views Thread by Janaka | last post: by
6 posts views Thread by John | last post: by
2 posts views Thread by epigram | last post: by
1 post views Thread by jelle.huygen | last post: by
reply views Thread by Scott Roberts | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.