Global variables in c#.net

后端 未结 6 1682
长情又很酷
长情又很酷 2020-11-28 05:08

How can I set a global variable in a C# web application?

What I want to do is to set a variable on a page (master page maybe) and access this variable from any page.

6条回答
  •  情歌与酒
    2020-11-28 05:40

    You can create a base class in your application that inherits from System.Web.UI.Page. Let all your pages inherit from the newly created base class. Add a property or a variable to your base class with propected access modifier, so that it will be accessed from all your pages in the application.

提交回复
热议问题