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. save page state after post back

save page state after post back

Scheduled Pinned Locked Moved ASP.NET
javascriptdatabasetutorialquestion
4 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.
  • A Offline
    A Offline
    Abdul Rahman Hamidy
    wrote on last edited by
    #1

    Dear All, I have two listBox in my webpage which i am adding items from one to other using Javascript works fine like i have source and destination listboxes. i am adding items from source to destination using javascript and source is binded with datasource. after post every thing is cleared from destination listbox. any ideas how to save the state of both listboxes after postback? i enabled page viewstate to true and both listbox view state to true but seems it doesent work and the same i enabled pageviewstate in web.config file no success

    Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

    R V 2 Replies Last reply
    0
    • A Abdul Rahman Hamidy

      Dear All, I have two listBox in my webpage which i am adding items from one to other using Javascript works fine like i have source and destination listboxes. i am adding items from source to destination using javascript and source is binded with datasource. after post every thing is cleared from destination listbox. any ideas how to save the state of both listboxes after postback? i enabled page viewstate to true and both listbox view state to true but seems it doesent work and the same i enabled pageviewstate in web.config file no success

      Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      If you are using a button to trigger the postback you could examine the data in each listbox within that event and store the data in some way (Session, ViewState, etc) and repopulate the boxes during the OnLoad event taking into account that this is a PostBack so you might have a method like:

      protected override void OnLoad(EventArgs e)
      {
      base.OnLoad(e);

      if (IsPostBack)
      {
      	// Populate the controls with the data saved on the postback event.
      }
      else
      {
      	// Do the initial databind for the controls.
      }
      

      }

      That should get you started.

      me, me, me "The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!" Larry Niven

      1 Reply Last reply
      0
      • A Abdul Rahman Hamidy

        Dear All, I have two listBox in my webpage which i am adding items from one to other using Javascript works fine like i have source and destination listboxes. i am adding items from source to destination using javascript and source is binded with datasource. after post every thing is cleared from destination listbox. any ideas how to save the state of both listboxes after postback? i enabled page viewstate to true and both listbox view state to true but seems it doesent work and the same i enabled pageviewstate in web.config file no success

        Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        Hey Abdul, Changes done in the client-side using JavaScript will not save it ViewState. To ASP.NET, it doesn't know that you have changed something. To fix this, use a hiddenfield. When you hit the button, get the list of item into the hiddenfield with delimiters. Once the page is back, fill the list with the items with the hiddenfield value. Only HiddenField can maintain states all the times.

        Castle Rider

        What if I freeze??? Don't forget to breath...

        My: Website | Yahoo Group | Blog Spot

        A 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          Hey Abdul, Changes done in the client-side using JavaScript will not save it ViewState. To ASP.NET, it doesn't know that you have changed something. To fix this, use a hiddenfield. When you hit the button, get the list of item into the hiddenfield with delimiters. Once the page is back, fill the list with the items with the hiddenfield value. Only HiddenField can maintain states all the times.

          Castle Rider

          What if I freeze??? Don't forget to breath...

          My: Website | Yahoo Group | Blog Spot

          A Offline
          A Offline
          Abdul Rahman Hamidy
          wrote on last edited by
          #4

          Thanks, HiddenField do save the status, Its really appreciated.

          Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

          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