The problem with web pages is that global variables are useless, as the page is regenerated on each request.
The best place to store it if you are returning to the same page is in the ViewState, or the Session if you need to persist it across web pages.
As for the reason it work, I am unsure. Normally, the value would stay as 0 as the compiler default it to 0.
Regards,
Dom
|