asp.net 弹出警告窗口实现代码
程序员文章站
2024-03-09 08:02:52
复制代码 代码如下:/// /// 提供一个可选“是”“否”的弹出窗口,若选是,则跳到url1,选否则跳到url2 ///
/// <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;
}