简单的问题,关于引用类~
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来用
------解决方案--------------------放到app_code去
------解决方案--------------------在网站中,这样才行。
public class Message
{
/// <summary>
/// 显示弹出消息
/// </summary>
/// <param name= "page "> 要弹出消息的页面 </param>
/// <param name= "msg "> 要显示的消息 </param>
public static void ShowMessage(System.Web.UI.Page page, string msg)
{
string script = " <script language=javascript> ";
script += "alert(\ " " + msg + "\ ") ";
script += " </script> ";
if (!page.ClientScript.IsClientScriptBlockRegistered(page.GetType(), "clientscript "))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "clientscript ", script);
}
}
}
=============
使用方法
Message.ShowMessage(this, "这里写信息 ");