C#几种在客户端跳转

1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open(XXX.aspx'',''_blank'')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location=XXX.aspx''</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog(XXX.aspx'')</script>")——原窗口保留,以对话框形式打开新窗口;

6.Response.Write("<script>window.showModalDialog(XXX.aspx'')</script>")——对话框形式打开新窗口,原窗口被代替;

 

 7....................

 /// <summary>
    /// 在客户端弹出消息框并跳转
    /// </summary>
    /// <param name="pageFor"></param>
    /// <param name="message">待显示的信息</param>
    /// <param name="redirectUrl">待跳转的地址</param>
    public static void ShowClientMessegeBoxAndRedirect(String message, String redirectUrl)
    {
        HttpContext.Current.Response.Write("<script language=\"javascript\" type=\"text/javascript\">");
        HttpContext.Current.Response.Write("alert('" + message + "');");
        HttpContext.Current.Response.Write("location.href='" + redirectUrl + "';");
        HttpContext.Current.Response.Write("</script>");
        HttpContext.Current.Response.End();
    }
    /// <summary>
    /// 测试一下  看看效果
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnTest_Click(object sender, EventArgs e)
    {
        ShowClientMessegeBoxAndRedirect("测试成功","http://www.baidu.com/");
    } 

posted @ 2009-12-15 14:55  不必太用力  阅读(343)  评论(0编辑  收藏  举报