using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Public
{
/***************************************
/// MessageBox 的摘要说明。
***************************************/
public class MessageBox
{
/// <summary>
/// 构造函数
/// </summary>
public MessageBox() { }
/// <summary>
/// 消息提示
/// 调用方法: MessageBox.Show(Page, this, "是否可以呢!");
/// </summary>
/// <param name="page0">参数:Page </param>
/// <param name="this0">参数:this </param>
/// <param name="str">参数:显示文本内容 </param>
public static void Show(Page page0, Page this0, string str)
{
StringBuilder sb = new StringBuilder("");
sb.Append("alert('" + str + "');");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "Show"))
{
cs.RegisterStartupScript(this0.GetType(), "Show", sb.ToString(), true);
}
}
/// <summary>
/// 打开新页面
/// </summary>
/// <param name="page0">参数:Page</param>
/// <param name="this0">参数:this</param>
/// <param name="url">参数:新页面地址</param>
/// <param name="target">打开页面的方式</param>
public static void OpenUrl(Page page0, Page this0, string url, string target)
{
StringBuilder sb = new StringBuilder("");
sb.Append("window.open('" + url + "','" + target + "');");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "OpenUrl"))
{
cs.RegisterStartupScript(this0.GetType(), "OpenUrl", sb.ToString(), true);
}
}
/// <summary>
/// 弹出消息提示,并且打开新页面
/// </summary>
/// <param name="page0">参数:Page</param>
/// <param name="this0">参数:this</param>
/// <param name="str">参数:消息提示文本内容</param>
/// <param name="url">参数:新页面地址</param>
public static void ShowUrl(Page page0, Page this0, string str, string url)
{
StringBuilder sb = new StringBuilder("");
sb.Append("alert('" + str + "');");
sb.Append("document.location.href='" + url + "';");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "ShowUrl"))
{
cs.RegisterStartupScript(this0.GetType(), "ShowUrl", sb.ToString(), true);
}
}
/// <summary>
/// 非模态显示
/// </summary>
/// <param name="page0"></param>
/// <param name="this0"></param>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
public static void Show(Page page0, Page this0, string url, int width, int height)
{
//strreturnval=window.showModalDialog('../Public/Pub_SpxxView.aspx','window','dialogWidth=500px;dialogHeight=410px');
//window.document.all("allvalue").value = strreturnval;
StringBuilder sb = new StringBuilder("");
sb.Append("ReturnValue = window.showModelessDialog('" + url + "', window ,'dialogWidth=" + width.ToString() + "px;dialogHeight=" + height.ToString() + "px');");
sb.Append("");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "ShowDialog"))
{
cs.RegisterStartupScript(this0.GetType(), "ShowDialog", sb.ToString(), true);
}
}
/// <summary>
/// 模态显示
/// </summary>
public static void ShowDialog(Page page0, Page this0, string url, int width, int height)
{
StringBuilder sb = new StringBuilder("");
sb.Append("ReturnValue = window.showModalDialog('" + url + "', window ,'dialogWidth=" + width.ToString() + "px;dialogHeight=" + height.ToString() + "px');");
sb.Append("");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "ShowDialog"))
{
cs.RegisterStartupScript(this0.GetType(), "ShowDialog", sb.ToString(), true);
}
}
/// <summary>
/// 打开新浏览器
/// </summary>
/// <param name="page0">参数:Page</param>
/// <param name="this0">参数:this</param>
/// <param name="url">参数:新页面地址</param>
public static void Redirect(Page page0, Page this0, string url)
{
StringBuilder sb = new StringBuilder("");
sb.Append("window.open('" + url + "','right');");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "Redirect"))
{
cs.RegisterStartupScript(this0.GetType(), "Redirect", sb.ToString(), true);
}
}
/// <summary>
/// 关闭页面窗口
///一般应用于服务器控件事件代码中,之前可执行其他代码;
/// </summary>
/// <param name="page0">参数:Page</param>
/// <param name="this0">参数:this</param>
public static void WinClose(Page page0, Page this0)
{
StringBuilder sb = new StringBuilder("");
sb.Append(" window.dialogArguments.location.href =window.dialogArguments.location.href;");
sb.Append(" window.close();");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "WinClose"))
{
cs.RegisterStartupScript(this0.GetType(), "WinClose", sb.ToString(), true);
}
}
/// <summary>
/// 关闭页面窗口
///一般应用于服务器控件事件代码中,之前可执行其他代码;
/// </summary>
/// <param name="page0">参数:Page</param>
/// <param name="this0">参数:this</param>
/// <param name="str">参数:返回值</param>
public static void WinClose(Page page0, Page this0, string str)
{
StringBuilder sb = new StringBuilder("");
sb.Append("window.returnValue = '" + str + "';");
sb.Append("window.close();");
ClientScriptManager cs = page0.ClientScript;
if (!cs.IsStartupScriptRegistered(this0.GetType(), "WinClose1"))
{
cs.RegisterStartupScript(this0.GetType(), "WinClose1", sb.ToString(), true);
}
}
}
}