use class to declare a static function: private class test { test() {} public static void function1() {...} }then in a .aspx file,you can transfer it in this method: test.function1();because static members should be transfered by class,not by object.
public Module 名称
'这里面放全局函数
end ModuleC#的写法public class Module
1) Application["param"] = "hello world";
2) 在 Global.asax 中 设静态变量: <%@ Application language="C#" ClassName="myGlobal"%>
<script runat="server">
public static string connStr="test";
</script> 应用页面:
string pageStr = myGlobal.connStr ; //result is "test";
3) 在 web.config 中:
<configuration>
<appSettings>
<add key="Application_Name" value="MyApplication" />
</appSettings>
</configuration> 在应用页面读取:
read.aspx
string myvalue = System.Configuration.ConfigurationSettings.AppSettings["Application_Name"]; // result is "MyApplication";
private class test
{
test()
{}
public static void function1()
{...}
}then in a .aspx file,you can transfer it in this method:
test.function1();because static members should be transfered by class,not by object.