送大家各种跳转,我都写注释了哦!
/// <summary>
/// 弹出警告框
public static void Alert(Page page, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>alert('" + str + "');</script>");
}
/// <summary>
/// 弹出警告框并返回前页
/// </summary>
public static void AlertAndBack(Page page, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>alert('" + str + "');history.go(-1);</script>");
}
/// <summary>
/// 弹出警告框并在框架内跳转到指定页
/// </summary>
public static void AlertAndGo(Page page, string alterStr, string urlStr)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>alert('" + alterStr + "');location.href='" + urlStr + "'</script>");
}
/// <summary>
/// 弹出警告框并在父框架打开到指定页
/// </summary>
public static void AlertAndParentOpen(Page page, string alterStr, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>alert('" + alterStr + "');window.open('" + str + "','_parent')</script>");
}
/// <summary>
/// 弹出新页面
/// </summary>
public static void OpenWindow(Page page, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>window.open('" + str + "')</script>");
}
/// <summary>
/// 工作区跳转
/// </summary>
public static void OpenWindow2(Page page, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>window.open('" + str + "','workFrame')</script>");
}
/// <summary>
/// 父窗口打开
/// </summary>
public static void OpenWindow3(Page page, string str)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>window.open('" + str + "','_parent')</script>");
}
/// <summary>
/// 关闭该页
/// </summary>
public static void Close(Page page)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "javascript", "<script language='javascript'>window.close();</script>");
}
/// <summary>
/// 弹出警告框,用于页面上添加有ScriptManager与UpdatePannel
/// </summary>
/// <param name="page">页面</param>
/// <param name="col">绑定的空间</param>
/// <param name="str">提示的字符串</param>
public static void Alert(Page page, Control col, string str)
{
ScriptManager.RegisterStartupScript(col, page.GetType(), "javascript", "alert('" + str + "');", true);
}