viewstate problem

Discussion in 'ASP .Net' started by Ralph Soons, Jan 23, 2004.

  1. Ralph Soons

    Ralph Soons Guest

    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()
    Ralph Soons, Jan 23, 2004
    #1
    1. Advertising

  2. Ralph Soons

    Teemu Keiski Guest

    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%...
    >> 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()
    >>
    >>
    >>
    Teemu Keiski, Jan 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Rush
    Replies:
    2
    Views:
    522
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,660
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,370
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    913
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    276
Loading...

Share This Page