- /// <summary>
- /// 弹出警告框提示对话框
- /// </summary>
- /// <param name="msg">弹出提示的信息</param>
- /// <param name="curPage">在哪里弹出</param>
- public static void MsgBox(string thismsg, Page curPage)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<script type='text/javascript'>");
- string script = "window.alert('" + thismsg + "');";
- sb.Append(script);
- sb.Append("</script>");
- Literal literal = new Literal();
- literal.Text = sb.ToString();
- curPage.Form.Controls.Add(literal);
- }
- /// <summary>
- /// 一个含有“确定”、“取消”的警告框
- /// </summary>
- /// <param name="_Msg">警告字串</param>
- /// <param name="URL">“确定”以后要转到预设网址</param>
- /// <returns>警告框JS</returns>
- public static void MsgBox1(string _Msg, string URL)
- {
- string StrScript;
- StrScript = ("<script language=javascript>");
- StrScript += "var retValue=window.confirm('" + _Msg + "');" + "if(retValue){window.location='" + URL + "';}";
- StrScript += ("</script>");
- System.Web.HttpContext.Current.Response.Write(StrScript);
- }
- /// <summary>
- /// 一个含有“确定”,点击以后就转到预设网址的警告框
- /// </summary>
- /// <param name="_Msg">警告字串</param>
- /// <param name="URL">“确定”以后要转到预设网址</param>
- /// <returns>警告框JS</returns>
- public static void MsgBox2(string _Msg, string URL)
- {
- string StrScript;
- StrScript = ("<script language=javascript>");
- StrScript += ("alert('" + _Msg + "');");
- StrScript += ("window.location='" + URL + "';");
- StrScript += ("</script>");
- System.Web.HttpContext.Current.Response.Write(StrScript);
- }
- /// <summary>
- /// 框架整个父页面的跳转
- /// </summary>
- /// <param name="_Msg">警告字串</param>
- /// <param name="URL">“确定”以后要转到预设网址</param>
- /// <returns>警告框JS</returns>
- public static void MyMsgBox2(string _Msg, string URL)
- {
- string StrScript;
- StrScript = ("<script language=javascript>");
- StrScript += ("alert('" + _Msg + "');");
- StrScript += ("window.parent.location.href='"+URL+"';");
- StrScript += ("</script>");
- System.Web.HttpContext.Current.Response.Write(StrScript);
- }
- /// <summary>
- /// 一个含有“确定”,点击关闭本页的警告框
- /// </summary>
- /// <param name="_Msg">警告字串</param>
- /// <returns>警告框JS</returns>
- public static void MsgBox3(string _Msg)
- {
- string StrScript;
- StrScript = ("<script language=javascript>");
- StrScript += ("alert('" + _Msg + "');");
- StrScript += ("window.close();");
- StrScript += ("</script>");
- System.Web.HttpContext.Current.Response.Write(StrScript);
- }
asp.net弹出对话框的封装
最新推荐文章于 2025-01-18 22:00:00 发布