你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

ASP.NET 弹出窗口(提示信息)

2021/11/30 18:24:39

Response.Write("<script language='javascript'>alert('弹出信息!');</script>");   //提示信息

 Response.Write($"<script language='javascript' defer>alert('更改成功!');window.location=\"Agency_AgencyList.aspx\";</script>");       //弹出信息并跳转

//如果直接写跳转,弹出信息不会提示,会直接到达新页面

/// <summary>
        /// MessageBox提示框
        /// </summary>
        /// <param name="Message">提示信息</param>
        public void MsgBox(string Message)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + Message + "');</script>");
            return;
        }

/// <summary>
        /// MessageBox提示并转向新页面
        /// </summary>
        /// <param name="Message">提示信息</param>
        /// <param name="URL">跳转的路径</param>
        public void MsgBox(string Message, string URL)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + Message + "');window.location='" + URL + "';</script>");
            return;
        }

 /// <summary>
        /// 弹出新窗口
        /// </summary>
        /// <param name="pagePath">页面路径</param>
        /// <param name="winName">新窗口名称</param>
        /// <param name="winWidth">新窗口宽度</param>
        /// <param name="winHeight">新窗口高度</param>
        public void openNewWin(string pagePath, string winName, int winWidth, int winHeight)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>window.open('" + pagePath + "','" + winName + "','toolbar=no,menubar=no,titlebar=no,directories=no,resizable=no,scroll=yes,status=no,fullscreen=no,center=yes,width=" + winWidth + ",height=" + winHeight + "');</script>");
            return;
        }

/// <summary>
        /// 关闭本窗口
        /// </summary>
        public void CloseWin()
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>window.opener=null;window.close();</script>");
            return;
        }

/// <summary>
        /// 弹出提示信息,并关闭本窗口
        /// <param name="Words">弹出提示信息内容</param>
        /// </summary>
        public void CloseWin(string Words)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + Words + "');window.opener=null;window.close();</script>");
            return;
        }


        /// <summary>
        /// 关闭本窗口并,重新加载父窗口.
        /// </summary>
        /// <param name="URL">父窗口要加载的URL</param>
        public void reLoadParentAndClose(string URL)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>window.opener.location='" + URL + "';window.close();</script>");
            return;
        }