asp.net 弹出警告窗口实现代码
(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )
复制代码 代码如下:
/// <summary>
/// 提供一个可选“是”“否”的弹出窗口,若选是,则跳到url1,选否则跳到url2
/// </summary>
/// <param name="strMsg"></param>
/// <param name="url1">选“是”</param>
/// <param name="url2">选“否”</param>
public static void confirm(string strMsg, string url1, string url2)
{
Page page = HttpContext.Current.Handler as Page;
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "var result = window.confirm('" + strMsg + "');if(result){window.location='" + url1 + "'}else{window.location='" + url2 + "'};",true);
return;
}
/// <summary>
/// 提供一个可选“是”“否”的弹出窗口,若选是,则跳到url1,选否则跳到url2
/// </summary>
/// <param name="strMsg"></param>
/// <param name="url1">选“是”</param>
/// <param name="url2">选“否”</param>
public static void confirm(string strMsg, string url1, string url2)
{
Page page = HttpContext.Current.Handler as Page;
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "var result = window.confirm('" + strMsg + "');if(result){window.location='" + url1 + "'}else{window.location='" + url2 + "'};",true);
return;
}
下一篇:asp.net 用户控件读取以及赋值