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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem using Static Variable...

Problem using Static Variable...

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.
  • N Offline
    N Offline
    N a r e s h P a t e l
    wrote on last edited by
    #1

    Hi, I am using static variables for storing some data like pageindex, some table data and like that. It works fine. No problems. But the scope of static variable is for whole application. I mean if there are 10 user connected to my application then they all share the same value of static variables. So it may creates some problems and it is obvious. So what should I do now. Because application is now completely developed. So should I use ViewState in place of all Static variables or what? So please give me way for this. Thanks in advance.

    Naresh Patel

    _ 1 Reply Last reply
    0
    • N N a r e s h P a t e l

      Hi, I am using static variables for storing some data like pageindex, some table data and like that. It works fine. No problems. But the scope of static variable is for whole application. I mean if there are 10 user connected to my application then they all share the same value of static variables. So it may creates some problems and it is obvious. So what should I do now. Because application is now completely developed. So should I use ViewState in place of all Static variables or what? So please give me way for this. Thanks in advance.

      Naresh Patel

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      It depends what scope you want for you variables. If you want it to be for that user only then you can use session or if you just want to have that for the life of that page then you can use viewstate.

      Apurva Kaushal

      N 1 Reply Last reply
      0
      • _ _AK_

        It depends what scope you want for you variables. If you want it to be for that user only then you can use session or if you just want to have that for the life of that page then you can use viewstate.

        Apurva Kaushal

        N Offline
        N Offline
        N a r e s h P a t e l
        wrote on last edited by
        #3

        Yaa But the number of session variables increase it may deduce the performance as I think. And the viewstate store all data into the page so it may also affect performance.

        Naresh Patel

        C _ 2 Replies Last reply
        0
        • N N a r e s h P a t e l

          Yaa But the number of session variables increase it may deduce the performance as I think. And the viewstate store all data into the page so it may also affect performance.

          Naresh Patel

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          N a r e s h P a t e l wrote:

          Yaa But the number of session variables increase it may deduce the performance

          Well the data has to be stored SOMEWHERE! I'd go with Session.


          Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

          1 Reply Last reply
          0
          • N N a r e s h P a t e l

            Yaa But the number of session variables increase it may deduce the performance as I think. And the viewstate store all data into the page so it may also affect performance.

            Naresh Patel

            _ Offline
            _ Offline
            _AK_
            wrote on last edited by
            #5

            But if you are just storing some small value in session it won't affect the performance that much. And also as Colin told you have to store it somewhere so you can choose you way.

            Apurva Kaushal

            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