Sunday, April 1, 2012

C# loses variable's value on postback

Problem
C# loses variable's value on postback

Impact
can't get variable's value.

Solution
C# is executed on server and then it sends result to the client using HTTP protocol.
and as you may know HTTP protocol is a stateless protocol.
so after sending result to the client the server doesn't know what was the value of that variable on previous request.
so if you want to store that variables value then you can use session or viewstate or hidden field.
and you can get back that value upon postback.

No comments:

Post a Comment