Asp.Net里面的MessageBox

    /// <summary>
    /// 弹出消息框
    /// </summary>
    /// <param name="msg"></param>
    public void MessageBox( string msg)
    {
        msg = msg.Replace("'", "\\'");
        msg = msg.Replace("\r\n", "\\r\\n");
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", string.Format("<script>alert('{0}')</script>", msg));
    }

    /// <summary>
    /// 弹出消息框并跳转到新页面
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="reUrl">跳转url</param>
    public void MessageBox(string msg,string reUrl)
    {
        msg = msg.Replace("'", "\\'");
        msg = msg.Replace("\r\n", "\\r\\n");
        Response.Write(string.Format("<script>alert('{0}');location.href='{1}'</script>", msg, reUrl));
        Response.End();
    }

你可能感兴趣的:(asp.net)