Variables in Code Pages

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a variable on a Code Behind page that is declared Private x as
integer. Somewhere in a method on that page I set the value of x to 5. When
a post back occurs the variable is set back to 0. Therefore the solution is
to save the variable to a Session variable so that when I need to refer to
it, it still holds it value. Is this correct or am I missing something?
 
You can also use the ViewState to store the value of your variable between
posts. It is also possible that you will need a static or an Application
variable instead. You should tell use more about your exact needs.
 
Back
Top