Environment versions
Network:
Windows 2008 Server
>>>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.
>
>I ended up using Session variable. So far, in my testing, it works. I sent update to the customer for testing too.
Hi,
Session would work but since it's just a simple string variable and is page specific using ViewState might be a better choice in this case.
Regards,
Viv
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only