ASP.NET 弹出提示框所有种类

11 篇文章 0 订阅
9 篇文章 0 订阅

ASP.NET 弹出提示框所有种类

 

 

添加一个类:把下面的文件放在类中就可以了。

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;

  public  class MessageBox
    {
      public  MessageBox()
        {

        }

        /// <summary>
        /// 警告框
        /// </summary>
        /// <param name="_Msg">警告字串</param>
        /// <returns>警告框JS</returns>
        public  void MsgBox(string _Msg)
        {
            string StrScript;
            StrScript = ("<script language=javascript>");
            StrScript += ("alert('" + _Msg + "');");
            StrScript += ("</script>");
            System.Web.HttpContext.Current.Response.Write(StrScript);
        }
        /// <summary>
        /// 一个含有“确定”、“取消”的警告框
        /// </summary>
        /// <param name="_Msg">警告字串</param>
        /// <param name="URL">“确定”以后要转到预设网址</param>
        /// <returns>警告框JS</returns>
        public 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 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);
        }

      public static void MsgBox22(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>
        /// <returns>警告框JS</returns>
        public  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);
        }
        /// <summary>
        /// 一个含有“确定”,点击返回先前的网页警告框
        /// </summary>
        /// <param name="_Msg">警告字串</param>
        /// <param name="BackLong">要倒退几步</param>
        /// <returns>警告框JS</returns>
        public  void alert_history(string _Msg, int BackLong)
        {
            string StrScript;
            StrScript = ("<script language=javascript>");
            StrScript += ("alert('" + _Msg + "');");
            StrScript += ("history.go('" + BackLong + "')");
            StrScript += ("</script>");
            System.Web.HttpContext.Current.Response.Write(StrScript);
        }

        /// <summary>
        /// 一个含有“确定”,点击后关闭自己,刷新父窗口警告框
        /// </summary>
        /// <param name="_Msg">警告字串</param>
        /// <returns>警告框JS</returns>
        public  void alert_reloadwin(string _Msg)
        {
            string StrScript;
            StrScript = ("<script language=javascript>");
            StrScript += ("alert('" + _Msg + "');");
            StrScript += ("window.opener.location.href=window.opener.location.href;window.close();");
            StrScript += ("</script>");
           System.Web.HttpContext.Current.Response.Write(StrScript);
        }

        /// <summary>
        /// 弹出对话框
        /// </summary>
        /// <param name="page">页面</param>
        /// <param name="content">message信息</param>
        public static void alert(System.Web.UI.Page page, string content)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), " ", "<script language='javascript'>alert('" + content + "');</script>");
        }

        /// <summary>
        /// 弹出对话框
        /// </summary>
        /// <param name="page">页面</param>
        /// <param name="content">message信息</param>
        public static void alert(System.Web.UI.Page page, string content,String _daiMa)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), " ", "<script language='javascript'>alert('" + content + "');"+_daiMa.Replace("/"","'")+"</script>");
        }


      public static void alert(System.Web.UI.Page page, object _code)
      {
          page.ClientScript.RegisterStartupScript(page.GetType(), "onLoad", "<script language='javascript'>" + _code + "</script>");
      }

    } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值