//显示JavaScript的Alert信息
public static void ShowMsg(Page thisPage, string AlertMessage)
{
Literal txtMsg = new Literal();
txtMsg.Text = "<script id='theMessage'>alert(\"" + AlertMessage + "\");</script>" + "<BR/>";
thisPage.Controls.Add(txtMsg);
}
/// <summary>
/// 显示JavaScript的Alert信息,加跳转
/// </summary>
/// <param name="thisPage"></param>
/// <param name="AlertMessage"></param>
public static void ShowMsg(Page thisPage,string AlertMessage, string URL)
{
Literal txtMsg = new Literal();
//为空则跳转到当前页面
URL = URL == string.Empty ? GetRequest.GetUrl() : GetRequest.GetHostUrl() +"/"+ URL;
txtMsg.Text = "<script id='theMessage'>alert('" + AlertMessage + "');";
txtMsg.Text += "window.location='" + URL + "';</script></script>";
thisPage.Controls.Add(txtMsg);
}
/// <summary>
/// 获得当前完整Url地址
/// </summary>
/// <returns>当前完整Url地址</returns>
public static string GetUrl()
{
return HttpContext.Current.Request.Url.ToString();
}
/// <summary>
/// 得到当前URL,带端口
/// </summary>
/// <returns></returns>
public static string GetHostUrl()
{
HttpRequest request = System.Web.HttpContext.Current.Request;
if (!request.Url.IsDefaultPort)
{
return "http://" + string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString());
}
return "http://" + request.Url.Host;
}