当前位置: 代码迷 >> ASP >> asp.net讯息提示框代码
  详细解决方案

asp.net讯息提示框代码

热度:123   发布时间:2012-12-18 12:43:41.0
asp.net消息提示框代码

/// <summary>
    /// 显示消息提示对话框
    /// </summary>
    /// <param name="page">当前页面指针,一般为this</param>
    /// <param name="msg">提示信息</param>
    public static void Show(Page page, string msg)
    {
        ClientScriptManager cs = page.ClientScript;
        String csname = "PopupScript";
        Type cstype = page.GetType();

        cs.RegisterStartupScript(cstype, csname, "<script language=\"javascript\">alert(\"" + msg + "\");</script>");
    }

    /// <summary>
    /// 显示消息对话框并进行页面跳转
    /// </summary>
    /// <param name="page">当前页面指针,一般为this</param>
    /// <param name="msg">提示信息</param>
    /// <param name="url">目标URL</param>
    public static void ShowAndRedirect(Page page, string msg, string url)
    {
        ClientScriptManager cs = page.ClientScript;
        String csname = "PopupScript";
        Type cstype = page.GetType();

        cs.RegisterStartupScript(cstype, csname, "<script language=\"javascript\">alert(\"" + msg + "\");location.href=\"" + url + "\"</script>");
    }

    public static void ShowAndRedirect(Page page, string msg, string url, string flag)
    {
        ClientScriptManager cs = page.ClientScript;
        string csname = "PopupScript";
        Type cstype = page.GetType();

        cs.RegisterStartupScript(cstype, csname, "<script language=\"javascript\">alert(\"" + msg + "\");" + flag + ".location.href=\"" + url + "\"</script>");

    }

    public static void ShowAndBack(Page page, string msg)
    {
        ClientScriptManager cs = page.ClientScript;
        string csname = "PopupScript";
        Type cstype = page.GetType();

        cs.RegisterStartupScript(cstype, csname, "<script language=\"javascript\">alert(\"" + msg + "\");history.back();</script>");
    }
?
  相关解决方案