zoukankan      html  css  js  c++  java
  • asp.net弹出对话的封装

     
    1.         /// <summary>
    2.         /// 弹出警告框提示对话框
    3.         /// </summary>
    4.         /// <param name="msg">弹出提示的信息</param>
    5.         /// <param name="curPage">在哪里弹出</param>
    6.         public static void MsgBox(string thismsg, Page curPage)
    7.         {
    8.             StringBuilder sb = new StringBuilder();
    9.             sb.Append("<script type='text/javascript'>");
    10.             string script = "window.alert('" + thismsg + "');";
    11.             sb.Append(script);
    12.             sb.Append("</script>");
    13.             Literal literal = new Literal();
    14.             literal.Text = sb.ToString();
    15.             curPage.Form.Controls.Add(literal);
    16.         }
    17.         /// <summary>
    18.         /// 一个含有“确定”、“取消”的警告框
    19.         /// </summary>
    20.         /// <param name="_Msg">警告字串</param>
    21.         /// <param name="URL">“确定”以后要转到预设网址</param>
    22.         /// <returns>警告框JS</returns>
    23.         public static void MsgBox1(string _Msg, string URL) 
    24.         { 
    25.             string StrScript; 
    26.             StrScript = ("<script language=javascript>"); 
    27.             StrScript += "var retValue=window.confirm('" + _Msg + "');" + "if(retValue){window.location='" + URL + "';}"
    28.             StrScript += ("</script>"); 
    29.             System.Web.HttpContext.Current.Response.Write(StrScript); 
    30.         } 
    31.         /// <summary>
    32.         /// 一个含有“确定”,点击以后就转到预设网址的警告框
    33.         /// </summary>
    34.         /// <param name="_Msg">警告字串</param>
    35.         /// <param name="URL">“确定”以后要转到预设网址</param>
    36.         /// <returns>警告框JS</returns>
    37.         public static void MsgBox2(string _Msg, string URL) 
    38.         { 
    39.             string StrScript; 
    40.             StrScript = ("<script language=javascript>"); 
    41.             StrScript += ("alert('" + _Msg + "');"); 
    42.             StrScript += ("window.location='" + URL + "';"); 
    43.             StrScript += ("</script>"); 
    44.             System.Web.HttpContext.Current.Response.Write(StrScript);
    45.         }
    46.         /// <summary>
    47.         /// 框架整个父页面的跳转
    48.         /// </summary>
    49.         /// <param name="_Msg">警告字串</param>
    50.         /// <param name="URL">“确定”以后要转到预设网址</param>
    51.         /// <returns>警告框JS</returns>
    52.         public static void MyMsgBox2(string _Msg, string URL)
    53.         {
    54.             string StrScript;
    55.             StrScript = ("<script language=javascript>");
    56.             StrScript += ("alert('" + _Msg + "');");
    57.             StrScript += ("window.parent.location.href='"+URL+"';");
    58.             StrScript += ("</script>");
    59.             System.Web.HttpContext.Current.Response.Write(StrScript);
    60.         }
    61.         /// <summary>
    62.         /// 一个含有“确定”,点击关闭本页的警告框
    63.         /// </summary>
    64.         /// <param name="_Msg">警告字串</param>
    65.         /// <returns>警告框JS</returns>
    66.         public static void MsgBox3(string _Msg) 
    67.         { 
    68.             string StrScript; 
    69.             StrScript = ("<script language=javascript>"); 
    70.             StrScript += ("alert('" + _Msg + "');"); 
    71.             StrScript += ("window.close();"); 
    72.             StrScript += ("</script>"); 
    73.             System.Web.HttpContext.Current.Response.Write(StrScript);
    74.         }
  • 相关阅读:
    Vue(五)模板
    2.typescript-你好世界
    1.typescript-安装
    jquery事件冒泡
    jquery中animate的使用
    Python 环境管理
    CentOS yum 源修改
    Node.js
    端口
    CSV
  • 原文地址:https://www.cnblogs.com/dingdingmao/p/3146592.html
Copyright © 2011-2022 走看看