Code
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace XNCJWC.Utility
{
/// <summary>
/// 一些Java script调用
/// </summary>
public class JScript
{
#region 重定Url
/// <summary>
/// 重定Url
/// </summary>
/// <param name="toUrl">新url地址</param>
public static void RedirectUrl(string toUrl)
{
HttpContext.Current.Response.Redirect(toUrl);
}
#endregion
#region 弹出消息
/// <summary>
/// 弹出消息
/// </summary>
/// <param name="message">消息内容</param>
public static void Alert(string message)
{
HttpContext.Current.Response.Write("<script language='javascript'>alert('" + message + "');</script>");
}
#endregion
#region Close the window, return to the previous history Cancel close page /// <Summary> /// close the window, return to the previous history Cancel close page /// </ Summary> public static void ColseWindow () { HttpContext.Current.Response.Write ( " <Script Language = 'JavaScript'> parent.opener = null; the window.close (); history.go (-1); </ Script> " ); HttpContext.Current.Response.End (); } #endregion #region pop-up message, and jump to a specific page /// <Summary> /// pop-up message, and jump to a specific page /// </ Summary> /// <param name = "message"> message content < / param>///
<param name = "redirectUrl"> Go page </ param> public static void alertAndRedirect ( String Message, String the redirectUrl) { String JS = " <Script Language = 'JavaScript'> Alert ( '{0}'); window. the location.replace ( '{}. 1'); </ Script> " ; HttpContext.Current.Response.Write ( String .Format (JS, Message, the redirectUrl)); } #endregion #region redirected to the history page /// <the Summary> /// redirected to the page of history /// </ the Summary> /// <param name="historyValue">
1/-1</param>
public static void GoHistory(int historyValue)
{
string js = "<script language='javascript'>history.go({0})</script>";
HttpContext.Current.Response.Write(string.Format(js, historyValue));
}
#endregion
}
}
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace XNCJWC.Utility
{
/// <summary>
/// 一些Java script调用
/// </summary>
public class JScript
{
#region 重定Url
/// <summary>
/// 重定Url
/// </summary>
/// <param name="toUrl">新url地址</param>
public static void RedirectUrl(string toUrl)
{
HttpContext.Current.Response.Redirect(toUrl);
}
#endregion
#region 弹出消息
/// <summary>
/// 弹出消息
/// </summary>
/// <param name="message">消息内容</param>
public static void Alert(string message)
{
HttpContext.Current.Response.Write("<script language='javascript'>alert('" + message + "');</script>");
}
#endregion
#region Close the window, return to the previous history Cancel close page /// <Summary> /// close the window, return to the previous history Cancel close page /// </ Summary> public static void ColseWindow () { HttpContext.Current.Response.Write ( " <Script Language = 'JavaScript'> parent.opener = null; the window.close (); history.go (-1); </ Script> " ); HttpContext.Current.Response.End (); } #endregion #region pop-up message, and jump to a specific page /// <Summary> /// pop-up message, and jump to a specific page /// </ Summary> /// <param name = "message"> message content < / param>///
<param name = "redirectUrl"> Go page </ param> public static void alertAndRedirect ( String Message, String the redirectUrl) { String JS = " <Script Language = 'JavaScript'> Alert ( '{0}'); window. the location.replace ( '{}. 1'); </ Script> " ; HttpContext.Current.Response.Write ( String .Format (JS, Message, the redirectUrl)); } #endregion #region redirected to the history page /// <the Summary> /// redirected to the page of history /// </ the Summary> /// <param name="historyValue">
1/-1</param>
public static void GoHistory(int historyValue)
{
string js = "<script language='javascript'>history.go({0})</script>";
HttpContext.Current.Response.Write(string.Format(js, historyValue));
}
#endregion
}
}
Reproduced in: https: //www.cnblogs.com/hubcarl/archive/2009/03/28/1423886.html