简单的问题,关于引用类~
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>
/// WebBase 鐨勬憳瑕佽鏄?
/// </summary>
public class MessageBox
{
System.Web.UI.Page p;
string message = "閿欒鎻愮ず ";
public MessageBox(System.Web.UI.Page Page)
{
p = Page;//鍒涘缓椤甸潰
//
// TODO: 鍦ㄦ澶勬坊鍔犳瀯閫犲嚱鏁伴€昏緫
//
}
public void Show(string message)
{
string script = " <script> alert( ' " + message + " ') </script> ";
p.Response.Write(script);
//Console.Write(script);
}
}
为什么其它地方我不能
messagebox.show来用
------解决方案--------------------string script = " <script> alert( ' " + message + " ') </script> ";
Response.Write(script);
在你要显示alert()的地方先这样写看可以吗
然后再找类的原因
------解决方案--------------------不用传page,用httpContext即可
-------------------------------------
public void Show(string msg)
{
System.Web.HttpContext.Current.Response.Write( " <script type= 'text/javascrippt '> alert( ' " + msg + " '); </script> ");
}
------解决方案--------------------做成靜態類就行了 ,放到app_code裏頭:
public static class MessageShow
{
public static void Show(string message)
{
string script = " <script> alert( ' " + message + " ') </script> ";
System.Web.HttpContext.Current.Response.Write(script);
}
}