I searched the Internet for an answer and saw that basically the variables are stored in the viewstate on the .prerender page. Then the value of the variable is returned to the page load event.
However, when I save a variable in the viewstate on prerender or load events, how can the viewstate save the value of the variable after changing it dynamically to codebehind?
Say, after the page loads, the user clicks a button that changes the value of the variable in its onClick event. Then the postback event raised after the button is clicked. For me, the new value should be lost and cannot be saved in the view if the variable is saved in the view only in the prerender event. Since the postback event does not trigger the prerender event, and the value cannot be saved.
Should I keep a variable in the view before starting the feedback event?
Am I really wrong? If so, how can the viewstate store the new value of the variable if the data store is stored in the prerender event?
Thanks for the reply in advance.
source
share