写一个类,
类里可以有静态方法、一般方法、设置属性、参数等内容使用的时候,直接new一个就好了

解决方案 »

  1.   

    VB的写法
    public Module 名称
      '这里面放全局函数
    end ModuleC#的写法public class Module
      

  2.   

    基本有三招:
        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";
      

  3.   

    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.