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. Accessing viewstate from Component Object

Accessing viewstate from Component Object

Scheduled Pinned Locked Moved ASP.NET
question
3 Posts 2 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.
  • S Offline
    S Offline
    Simon_uk
    wrote on last edited by
    #1

    Hello all, I have created a new object based on System.ComponentModel.Component and need to store information between postbacks. At the moment I am using Session, but really need to use the Page's Viewstate. However, I can't see a way to get access to the Page object. Can anyone tell me how this is done? (Or tell me its not possible!) Thanks for your assistance. Simon.

    A 1 Reply Last reply
    0
    • S Simon_uk

      Hello all, I have created a new object based on System.ComponentModel.Component and need to store information between postbacks. At the moment I am using Session, but really need to use the Page's Viewstate. However, I can't see a way to get access to the Page object. Can anyone tell me how this is done? (Or tell me its not possible!) Thanks for your assistance. Simon.

      A Offline
      A Offline
      Andy Smith
      wrote on last edited by
      #2

      while you can cast HttpContext.Current.Handler to System.Web.UI.Page, the ViewState is a protected property. You can't access it from a seperate component. You would be better off deriving from System.Web.UI.Control.

      S 1 Reply Last reply
      0
      • A Andy Smith

        while you can cast HttpContext.Current.Handler to System.Web.UI.Page, the ViewState is a protected property. You can't access it from a seperate component. You would be better off deriving from System.Web.UI.Control.

        S Offline
        S Offline
        Simon_uk
        wrote on last edited by
        #3

        Yeah, thats a good point. I forgot it was protected. :( Thanks for the info about casting the current http handler to a Page though - didn't realize I could do that. Unfortunately deriving from Control isn't an option at this stage. :( Thanks again, Simon.

        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