Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variables getting reset
Message
General information
Forum:
ASP.NET
Category:
Migration
Title:
Variables getting reset
Miscellaneous
Thread ID:
00681367
Message ID:
00681367
Views:
50
On a web form, I declare a vairable (int) in the class of the form which I intend to use at various places in the code-behind. For example, a primary key that may be used for a data action in one or more places. The variable gets populated early in the page_load event. However, each time a postback happens, the variable gets reset to zero. I can re-establish it on postback which seems redundant, or I can declare it static initially (either private or protected), and then it holds its value. Declaring it as a static is the easiest, but that doesn't seem like the right solution as I understand the definition of static.

Am I on the right track here, or is there a better way to get the variable to persist.

Dick Harrold
=========================================
Dick Harrold [DickHarrold@Yahoo.com]
Next
Reply
Map
View

Click here to load this message in the networking platform