Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Session State variables within UserControls [modified]

Session State variables within UserControls [modified]

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netwinformsdebugging
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Travis D Mathison
    wrote on last edited by
    #1

    Scenario: - I have session state variables being saved and loaded from an ASP.NET page. - I have session state variables being set from within a UserControl that exists on that same page. Problem: - When I set a session state variable within the codebehind page of the UserControl and the page performs a postback I am unable to access the session state variable that was set within the UserControl during the OnInit method of the ASP.NET page that the control is on? - I am checking this by enumerating the session state variable collection for the page at both the OnInit and OnLoad methods of the page and the controls session state variables are not available at either. However, after the page has loaded I look at the trace information and see that the user controls session state variables are there (but not in the collection during the pages OnLoad event....) Question: - In regards to the accessability of the UserControls session state variables on the page: Are the session state variables loaded into the pages session state collection during the loading of the control itself (which is why I cant access them during the OnInit phase of the Page itself?) - Shouldn't Session state variables be accessable to the page and all children controls of that page for that user? I'm going to try to move some of the code that uses the session variable to a later rendering phase of which it's accessable however there is some things I'm doing that have to be done in the OnInit, OnPreRender, etc. page load phases... Thanks for any insight you can provide =P -- modified at 6:34 Friday 14th July, 2006

    G B 2 Replies Last reply
    0
    • T Travis D Mathison

      Scenario: - I have session state variables being saved and loaded from an ASP.NET page. - I have session state variables being set from within a UserControl that exists on that same page. Problem: - When I set a session state variable within the codebehind page of the UserControl and the page performs a postback I am unable to access the session state variable that was set within the UserControl during the OnInit method of the ASP.NET page that the control is on? - I am checking this by enumerating the session state variable collection for the page at both the OnInit and OnLoad methods of the page and the controls session state variables are not available at either. However, after the page has loaded I look at the trace information and see that the user controls session state variables are there (but not in the collection during the pages OnLoad event....) Question: - In regards to the accessability of the UserControls session state variables on the page: Are the session state variables loaded into the pages session state collection during the loading of the control itself (which is why I cant access them during the OnInit phase of the Page itself?) - Shouldn't Session state variables be accessable to the page and all children controls of that page for that user? I'm going to try to move some of the code that uses the session variable to a later rendering phase of which it's accessable however there is some things I'm doing that have to be done in the OnInit, OnPreRender, etc. page load phases... Thanks for any insight you can provide =P -- modified at 6:34 Friday 14th July, 2006

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The user control doesn't have any separate session variables, there is only one Session object for the request. If there is no session variable, it simply hasn't been created yet. You have to wait until the user control has been created. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • T Travis D Mathison

        Scenario: - I have session state variables being saved and loaded from an ASP.NET page. - I have session state variables being set from within a UserControl that exists on that same page. Problem: - When I set a session state variable within the codebehind page of the UserControl and the page performs a postback I am unable to access the session state variable that was set within the UserControl during the OnInit method of the ASP.NET page that the control is on? - I am checking this by enumerating the session state variable collection for the page at both the OnInit and OnLoad methods of the page and the controls session state variables are not available at either. However, after the page has loaded I look at the trace information and see that the user controls session state variables are there (but not in the collection during the pages OnLoad event....) Question: - In regards to the accessability of the UserControls session state variables on the page: Are the session state variables loaded into the pages session state collection during the loading of the control itself (which is why I cant access them during the OnInit phase of the Page itself?) - Shouldn't Session state variables be accessable to the page and all children controls of that page for that user? I'm going to try to move some of the code that uses the session variable to a later rendering phase of which it's accessable however there is some things I'm doing that have to be done in the OnInit, OnPreRender, etc. page load phases... Thanks for any insight you can provide =P -- modified at 6:34 Friday 14th July, 2006

        B Offline
        B Offline
        bluewavestrider
        wrote on last edited by
        #3

        You know what to do yet you chose to ask the question? Anyway, you'll never get lost doing that. Just access the HttpCookie in the Pageload event. I suppose during init, variables havent been created yet. Live in fragments no longer. Only connect.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups