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. Can I use static variable in a page?

Can I use static variable in a page?

Scheduled Pinned Locked Moved ASP.NET
helpquestion
5 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.
  • M Offline
    M Offline
    MudkiSekhon
    wrote on last edited by
    #1

    I m building an application in which I redirect the user to a particular page. In the Page Load event of the that page , I assign a variable some value. Then I call the Button click event on that page. I have applied the !IsPostBack so that the Page Load event does not occur on clicking the button. Now the problem is that I want to use the value of that variable which i was population on Page Load event. Can I use that variable as static? I have a doubt in my mind that as I am simply redirecting the users to that page, the value of that variable could be set to some another value if another user is redirected to that page as the variable is static. Please help me to clarify my concept. Thanks, Sandy

    J 1 Reply Last reply
    0
    • M MudkiSekhon

      I m building an application in which I redirect the user to a particular page. In the Page Load event of the that page , I assign a variable some value. Then I call the Button click event on that page. I have applied the !IsPostBack so that the Page Load event does not occur on clicking the button. Now the problem is that I want to use the value of that variable which i was population on Page Load event. Can I use that variable as static? I have a doubt in my mind that as I am simply redirecting the users to that page, the value of that variable could be set to some another value if another user is redirected to that page as the variable is static. Please help me to clarify my concept. Thanks, Sandy

      J Offline
      J Offline
      jiturinku
      wrote on last edited by
      #2

      hi, if u want to access that variable on post back u have to define that variable as static . bye

      G 1 Reply Last reply
      0
      • J jiturinku

        hi, if u want to access that variable on post back u have to define that variable as static . bye

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        The problem is that all visitors share the same static variable... --- b { font-weight: normal; }

        M 1 Reply Last reply
        0
        • G Guffa

          The problem is that all visitors share the same static variable... --- b { font-weight: normal; }

          M Offline
          M Offline
          MudkiSekhon
          wrote on last edited by
          #4

          Can I store that variable in View state to remove this problem? because I don't want to share the variable between different users. Thanks, Sandy Sekhon

          G 1 Reply Last reply
          0
          • M MudkiSekhon

            Can I store that variable in View state to remove this problem? because I don't want to share the variable between different users. Thanks, Sandy Sekhon

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Yes. --- b { font-weight: normal; }

            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