复制代码 代码如下:
Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>"); (打开简洁窗口):
Respose.Write("<script language='javascript'>window.open('" + url + "','','resizable=1,scrollbars=0,status=1,menubar=no,toolbar=no,location=no, menu=no');</script>");
复制代码 代码如下:
public static void ShowMessage(System.Web.UI.Page page, string msg)
{
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "a", "alert('" + msg.ToString() + "');", true);
}
复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace WorkLogic
{
/// <summary>
/// 显示消息提示对话框。
/// </summary>
public class MessageBox
{
private MessageBox()
{
}
/// <summary>
/// 显示消息提示对话框
/// </summary>
/// <param>当前页面指针,一般为this</param>
/// <param>提示信息</param>
public static void ShowMessage(System.Web.UI.Page page, string msg)
{
//page.RegisterStartupScript("message", "alert('" + msg.ToString() + "');");
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "a", "alert('" + msg.ToString() + "');", true);
}
public static void ShowMessage(System.Web.UI.UserControl control, string msg)
{
control.Page.ClientScript.RegisterClientScriptBlock(control.Page.GetType(), "b", "alert('" + msg.ToString() + "');", true);
}
/// <summary>
/// 控件点击 消息确认提示框
/// </summary>
/// <param>当前页面指针,一般为this</param>
/// <param>提示信息</param>
public static void ShowConfirm(System.Web.UI.WebControls.WebControl Control, string msg)
{
//Control.Attributes.Add("onClick","if (!window.confirm('"+msg+"')){return false;}");
Control.Attributes.Add("onclick", "return confirm('" + msg + "');");
}
/// <summary>
/// 显示消息提示对话框,并进行页面跳转
/// </summary>
/// <param>当前页面指针,一般为this</param>
/// <param>提示信息</param>
/// <param>跳转的目标URL</param>
public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url, string frame)
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<script language='javascript' defer>");
Builder.AppendFormat("alert('{0}');", msg);
Builder.AppendFormat("top." + frame + ".location.href='{0}'", url);
Builder.Append("</script>");
page.ClientScript.RegisterStartupScript(page.GetType(), "message", Builder.ToString());
}
/// <summary>
/// 输出自定义脚本信息
/// </summary>
/// <param>当前页面指针,一般为this</param>
/// <param>输出脚本</param>
public static void ResponseScript(System.Web.UI.Page page, string script)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>" + script + "</script>");
}
/// <summary>
/// 显示消息提示对话框,并进行页面跳转
/// <param>当前页面指针,一般为this</param>
/// <param>提示信息</param>
/// <param>跳转的目标URL</param>
public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url)
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<script language='javascript' defer>");
Builder.AppendFormat("alert('{0}');", msg);
Builder.AppendFormat("top.location.href='{0}'", url);
Builder.Append("</script>");
page.ClientScript.RegisterStartupScript(page.GetType(), "message", Builder.ToString());
}
}
}
新闻热点
疑难解答
图片精选