When to save a variable in viewstate?
- by Umut
Hi,
I have searched the web for the answer and saw that mostly variables are saved in viewstate on page.prerender event.
However, when I save a variable in viewstate on prerender or load events, how can it store the changed value of the variable?
Let's say, after page load, user clicked a button and the value of the variable was changed in onClick event of the button. Then the postback event raised since the button was clicked. According to me, the new value should have been lost and cannot be saved in the viewstate if I save the variable in the viewstate only in prerender event.
Shouldn't I save the variable in the viewstate just before the postback event rises?
Am I wrong? If so, how can viewstate store the new value of the variable?
Thanks for the answer in advance..