How can I save variables in asp.net between postback? I'm using HttpContext.Current.Items but it always disposes after postback is there any other option to do that?
if your variable is serializable, and you can live with the client reading its value, and it should only live during the postbacks sequence in the scope of the page => you should use ViewState. Show activity on this post.
View state is the method that the ASP.NET page framework uses to preserve page and control values between round trips. When the HTML markup for the page is rendered, the current state of the page and values that must be retained during postback are serialized into base64-encoded strings.
If your variable is not serializable or you do not want the client to be able to read its value => use inProc Session
If your variable is serializable and you do not want the client to be able to read its value => use database Session
if your variable is serializable, and you can live with the client reading its value, and it should only live during the postbacks sequence in the scope of the page => you should use ViewState.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With