C# 中对一些消息处理的方法.
/// <summary>
/// 客户端脚本:alert(Msg) I;
/// </summary>
/// <param name="Msg">要显示的消息</param>
/// <returns>alert函数的客户端脚本</returns>
public static string Client_Alert(string Msg)
{
return "<script language="javascript">alert("" + Msg + "");</script>";
}
///<summary>
/// 客户端脚本:alert(Msg) II; ///</summary>
///<param name="Msg">要显示的消息</param>
///<param name="returnURL">返回地址</param>
///<returns>返回指定的URL</returns>
public static string Client_Alert(string Msg, string returnURL)
{
return "<script language="javascript">alert("" + Msg + "");location.href='" + returnURL + "';</script>";
}
/// <summary>
/// 客户端脚本:confrim(Msg) I;
/// </summary>
/// <param name="Msg">待确认的消息</param>
/// <param name="url">确认之后转向的地址</param>
/// <returns>confirm函数的客户端脚本</returns>
public static string Client_Confirm(string Msg, string url)
{
string scripts = "<script language="javascript">" +
"if (confirm('" + Msg + "')) " +
" { location.href='" + url + "'; }" +
"</script>";
return scripts;
}
/// <summary>
/// 客户端脚本:confrim(Msg) II;
/// </summary>
/// <param name="Msg">待确认的消息</param>
/// <param name="cfmurl">确认之后转向的地址</param>
/// <param name="retrunURL">取消之后转向的地址</param>
/// <returns>confirm函数的客户端脚本</returns>
public static string Client_Confirm(string Msg, string cfmurl, string retrunURL)
{
string scripts = "<script language="javascript">" +
"if (confirm('" + Msg + "')) " +
" { location.href='" + cfmurl + "'; }" +
"else { location.href='" + retrunURL + "'; }</script>";
return scripts;
}
/// <summary>
/// 关闭窗口无提示信息!
/// </summary>
public static string Client_CloseWindow()
{
return "<script>window.opener=null;window.close();</script>";
}
/// <summary>
/// 关闭 窗口前出现提示信息
/// </summary>
/// <param name="MSG">提示关闭信息</param>
public static string Client_CloseWindow(string MSG)
{
return "<script>if(confirm('" + MSG + "')){window.opener=null;window.close();}else{return false;}</script>";
}
/// <summary>
/// 客户端脚本:重定向网址
/// </summary>
/// <param name="URL">重定向的网址</param>
/// <param name="CopyHistory">是否记录历史</param>
/// <returns>重定向网址的客户端脚本块</returns>
public static string Client_Redirect(string URL, bool CopyHistory)
{
return (CopyHistory) ? "<script language="javascript">top.location.href='" + URL + "';</script>" : "<script language="javascript">top.location.replace('" + URL + "');</script>";
}
#endregion