Codebehind Variable State ?

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I'm writing an asp page with C# codebehind. I create a
page level variable. I then alter the variable by
assigning a new value in a private method. When I access
the vairable again from another private method, the
variable has the original value..

Am I missing a scope issue here? Any ideas welcome...

Thanks,
cj
 
Are you doing this on the same request to the server? Or on different
requests (i.e. after a click event).

If it is the latter, then the reason this is so is because HTTP is a
stateless protcol. The page object is recreated every time - it is not as if
the user is getting the same one on every request. If you need values to
persist between requests, you will need to use session or anothe persistence
mechanism.

If this is not the problem, please post your code...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top