做法:
创建一个webapplication,假设名称为webapplication1,在global.ASPx中的global类中增加一个静态的成员sgreeting.
public class global : system.web.httpapplication
{
public static string sgreeting = "china is great!";
……
}
在webform1中增加一个label,名称为label1.
在page_load()中为label1的text属性赋值。
private void page_load(object sender, system.eventargs e)
{
label1.text = webapplication1.global.sgreeting;
}
运行程序后将会看到china is great!