Static variable in asp.net page

前端 未结 5 2024
无人共我
无人共我 2020-12-25 14:24

I am having one doubt regarding the use of static variable in Asp.net pages.

I am having one page say UserDetails.aspx. In this page, I have one static variable to s

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 15:08

    static variable scope is application wide. numberOfReviews will be shared among all users. you need to use Session to store per user, so it is accessible in all pages. On the other hand, if you just need it on a specific page, you can save it in ViewState and can get it in post back.

提交回复
热议问题