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. ViewState is always null on Postback

ViewState is always null on Postback

Scheduled Pinned Locked Moved ASP.NET
questionxmlhelp
5 Posts 4 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.
  • A Offline
    A Offline
    AndyASPVB
    wrote on last edited by
    #1

    Hi I am really scratching my headache around on this one! At the moment I am undertaking a Proof of Concept project, and on a page I am loading an Xml Document, this xml document needs to be saved into a viewstate so, I have written aftering loading up the xml document: this.ViewState["tempDoc"] = xmlDoc; The load of the xml document happens by the user clicking a button. Now, I am not getting any errors at this stage. On the next page I have used: protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); } The problem being is that on this page I have no ViewState data! Even just calling the ViewState on the same page where I set it gives me the same problem. I have even tried setting simple data types like numbers and I am getting the same problem. What is going on???!!! The funny thing is though, I am not getting the problem with Session, but for this project, I can't use Session. Any ideas?????????????

    P N 2 Replies Last reply
    0
    • A AndyASPVB

      Hi I am really scratching my headache around on this one! At the moment I am undertaking a Proof of Concept project, and on a page I am loading an Xml Document, this xml document needs to be saved into a viewstate so, I have written aftering loading up the xml document: this.ViewState["tempDoc"] = xmlDoc; The load of the xml document happens by the user clicking a button. Now, I am not getting any errors at this stage. On the next page I have used: protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); } The problem being is that on this page I have no ViewState data! Even just calling the ViewState on the same page where I set it gives me the same problem. I have even tried setting simple data types like numbers and I am getting the same problem. What is going on???!!! The funny thing is though, I am not getting the problem with Session, but for this project, I can't use Session. Any ideas?????????????

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Hi Andy, I believe scope of ViewState is only on page level. Therefore in other page it would not available. On same page it should be work. Go through for deep concept: http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic10[^] Thanks

      Parwej Ahamad ahamad.parwej@gmail.com

      A 1 Reply Last reply
      0
      • P Parwej Ahamad

        Hi Andy, I believe scope of ViewState is only on page level. Therefore in other page it would not available. On same page it should be work. Go through for deep concept: http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic10[^] Thanks

        Parwej Ahamad ahamad.parwej@gmail.com

        A Offline
        A Offline
        AndyASPVB
        wrote on last edited by
        #3

        Hi I have tried it on the same page, but still got the same problem. My little test was on button click to set the ViewState but redirect to the same page. So, I am very unclear on how to solve this one!!! I really do need some help!!!

        T 1 Reply Last reply
        0
        • A AndyASPVB

          Hi I am really scratching my headache around on this one! At the moment I am undertaking a Proof of Concept project, and on a page I am loading an Xml Document, this xml document needs to be saved into a viewstate so, I have written aftering loading up the xml document: this.ViewState["tempDoc"] = xmlDoc; The load of the xml document happens by the user clicking a button. Now, I am not getting any errors at this stage. On the next page I have used: protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); } The problem being is that on this page I have no ViewState data! Even just calling the ViewState on the same page where I set it gives me the same problem. I have even tried setting simple data types like numbers and I am getting the same problem. What is going on???!!! The funny thing is though, I am not getting the problem with Session, but for this project, I can't use Session. Any ideas?????????????

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Obviously you need to ensure ViewState is enable at the page level, but also make sure it hasn't been explicitly disabled in the web.config, or the machine.config.


          I know the language. I've read a book. - _Madmatt

          1 Reply Last reply
          0
          • A AndyASPVB

            Hi I have tried it on the same page, but still got the same problem. My little test was on button click to set the ViewState but redirect to the same page. So, I am very unclear on how to solve this one!!! I really do need some help!!!

            T Offline
            T Offline
            trilokharry
            wrote on last edited by
            #5

            viewstate available only in same page and on post back means when you click any button then it's data will be available but if you will redirect to same page or another page on click of button no viewstate data will be available.

            You get the best out of others when you give the best of yourself.

            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