using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;/// <summary>
/// Summary description for globalfunc
/// </summary>
/// 
namespace globalfunc
{
    public class globalfuncc : System.Web.UI.Page
    {
        public void globalfuncf(ref int mm)
        {
            mm = mm + 1;
            
            Response.Write("<script language=javascript>alert(" + mm.ToString() + ");</script>");////这句出现错误。出错如下。。
        }    }
}这是我自定义的一个命名空间。我的本意是将其做为全局的函数来调用。
可是程序一到response.write...这句时就会报错,:Response is not available in this context.这是为何呢?如果在外面定义为一个函数则没有任何问题。我将上面所写的代码放在app_code中。请高手指教。

解决方案 »

  1.   

    response函数只能在*.aspx.cs中引用得到。。
      

  2.   

    string str1 = "<script>alert('" + mm.ToString()  + "')</script>";
    Response.Write(str1);
    看看
      

  3.   

    [code]
    public class PageDownload : Page
        {
            protected override void OnLoad(EventArgs e)
            {
                if (!IsPostBack)
                {                Response.ClearContent();
                    Response.ContentType = "application/stream";
                    Response.TransmitFile(Globals.FileRoot + @"App_Data\3\030002.wps");
                }
            }
        }
    [/code]