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. Maintain value across postbacks ?

Maintain value across postbacks ?

Scheduled Pinned Locked Moved ASP.NET
question
8 Posts 6 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.
  • D Offline
    D Offline
    digsy_
    wrote on last edited by
    #1

    I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

    V M H _ P 5 Replies Last reply
    0
    • D digsy_

      I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Use ViewState...

      D 1 Reply Last reply
      0
      • D digsy_

        I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

        M Offline
        M Offline
        Member_3259094
        wrote on last edited by
        #3

        there is a State Management by viewstate . it's keep the value in the object so when ever we want to get value from viewstate we have to do boxing. a example for that suppose you want to save a textbox value //this is use to save the date ViewState["name"]=textbox.text; //this is use to retrive the date; textbox.text=ViewState["name"].ToString(); another is session //this is use to save the date session["name"]=textbox.text; //this is use to retrive the date; textbox.text=session["name"].ToString(); I Think this will be helpfull to you. bye take care. -- modified at 9:14 Tuesday 10th April, 2007

        rajeev kumar sharma vri software pvt. ltd. new delhi India

        1 Reply Last reply
        0
        • D digsy_

          I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

          H Offline
          H Offline
          Harikrk
          wrote on last edited by
          #4

          You can use sessions for this

          1 Reply Last reply
          0
          • V varshavmane

            Use ViewState...

            D Offline
            D Offline
            digsy_
            wrote on last edited by
            #5

            Sorry - my question was more about whether a label is the correct control/method of persisting the value.

            V 1 Reply Last reply
            0
            • D digsy_

              Sorry - my question was more about whether a label is the correct control/method of persisting the value.

              V Offline
              V Offline
              varshavmane
              wrote on last edited by
              #6

              How will u maintain the different values??If u want only one value then u can use label...

              1 Reply Last reply
              0
              • D digsy_

                I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

                _ Offline
                _ Offline
                _mubashir
                wrote on last edited by
                #7

                Hi, Use hidden control... runat=server will make this available to access at the code behind as well Mubashir Every job is a self portrait of the person who did it.

                1 Reply Last reply
                0
                • D digsy_

                  I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.

                  P Offline
                  P Offline
                  Paddy Boyd
                  wrote on last edited by
                  #8

                  Use ViewState, e.g.

                  ViewState("something") = something;

                  This is 'encrypted' and hidden from the user on the page.

                  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