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. pass the values of variable in code Behind

pass the values of variable in code Behind

Scheduled Pinned Locked Moved ASP.NET
question
4 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.
  • N Offline
    N Offline
    Naif_Prof
    wrote on last edited by
    #1

    Hi, we use PostBackUrl passing values of controls from one page to anther page in encrypted way(FORM) can i use same method to pass the values of variable in code Behind of page 1 to code Behind of page 2? any one explain thanks a lot....

    P 1 Reply Last reply
    0
    • N Naif_Prof

      Hi, we use PostBackUrl passing values of controls from one page to anther page in encrypted way(FORM) can i use same method to pass the values of variable in code Behind of page 1 to code Behind of page 2? any one explain thanks a lot....

      P Offline
      P Offline
      perlmunger
      wrote on last edited by
      #2

      In your second page, look at using PreviousPage.FindControl() passing it the control ID of the control you want the data from in the first page. You'll have to typecast it to the proper control type to get the data, but this does work. I don't believe that this encrypts the data, but it is not visible in the URL. -Matt

      ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

      N 1 Reply Last reply
      0
      • P perlmunger

        In your second page, look at using PreviousPage.FindControl() passing it the control ID of the control you want the data from in the first page. You'll have to typecast it to the proper control type to get the data, but this does work. I don't believe that this encrypts the data, but it is not visible in the URL. -Matt

        ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

        N Offline
        N Offline
        Naif_Prof
        wrote on last edited by
        #3

        This is good But I mean how I can pass the values of variable in code behind of page 1 to page 2 thanks

        P 1 Reply Last reply
        0
        • N Naif_Prof

          This is good But I mean how I can pass the values of variable in code behind of page 1 to page 2 thanks

          P Offline
          P Offline
          perlmunger
          wrote on last edited by
          #4

          If all you want is to pass the value of a variable, just use your Session object:

          /// Add variable to Session object in Page1
          Session["variable_name"] = myVariable;

          And then in your second page

          /// Retrieve the variable you added in Page1
          string myVariable = Session["variable_name"].ToString();

          If this is not feasible because you don't want to use cookies (which Session uses by default), there is a way to enable cookieless sessions. -Matt

          ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

          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