Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set a private variable?
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01344645
Message ID:
01344667
Views:
12
>Hi,
>
>The title is not very clear so I will have to explain what I am trying to do.
>
>I have a form where I need to get/read a value of a Private string variable in Submit method. But the value to this private string variable is assigned in a MyTextField_TextChanged method. Here are the steps:
>
>ASP.NET form has a textbox that has a method MyTextField_TextChanged. User enters value in this textbox. In the MyTextField_TextChanged the program get some value from the database and assigns this value to a Private string variable. The value is set but then "lost" as soon as program returns focus back to the form. I thought initially that since both Submit method and MyTextField_TextChanged belong to the same class the value in the private variable will be "visible" but it does not work that way.
>
>Therefore, when user clicks on Submit the Submit method sees value in this variable as empty string.
>
>The only way I see possible doing it is via session variables. But is there another method?
>
>Thank you in advance for any suggestions.

If there is a postback between receiving this variable and retriving it, then it would be lost and you need to save it either in ViewState or in Session or in Cockie. Otherwise you can use a class variable declared on the class level.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform