代码改变世界

ASP.NET页面跳转

2010-04-20 11:46  Leason Li  阅读(286)  评论(0编辑  收藏  举报
代码
    public static void AlertAndBack(string msg)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(
"<script>alert(\"" + msg.Replace("\"""\\\"") + "\");window.history.back();</script>");
        HttpContext.Current.Response.End();
    }

    
public static void AlertAndGo(string msg, string gourl, string tager)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(
"<script>alert(\"" + msg.Replace("\"""\\\"") + "\");window." + tager + ".location.href='" + gourl + "'</script>");
        HttpContext.Current.Response.End();
    }

    
public static void AlertAndRedirect(string msg, string gourl)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(
"<script>alert(\"" + msg.Replace("\"""\\\"") + "\");window.location.href='" + gourl + "'</script>");
        HttpContext.Current.Response.End();
    }

    
public static void AlertAndClose(string msg)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(
"<script>alert(\"" + msg.Replace("\"""\\\"") + "\");window.close();</script>");
        HttpContext.Current.Response.End();
    }
    
public static void Alert(System.Web.UI.Page p, string msg)
    {
        p.ClientScript.RegisterStartupScript(p.GetType(), 
"alert""<script>alert(\"" + msg.Replace("\"""\\\"") + "\");</script>");
    }
  
public static void AlertAndRefresh(string msg)
    {

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(
"<script>alert(\"" + msg.Replace("\"""\\\"") + "\");history.go(-2);window.location.reload(); </script>");
        
//HttpContext.Current.Response.Write("<script>alert(\"" + msg.Replace("\"", "\\\"") + "\");parent.location.replace('DJIntegralAdmin.aspx'); </script>");
        HttpContext.Current.Response.End();
    }