• MessageBox类


     /// <summary>
        
    /// C#注册客户端js提示类
        
    /// </summary>
        public class MessageBox
        {
            
    /// <summary>
            
    /// C#注册客户端js提示
            
    /// </summary>
            public MessageBox()
            {
                
    //
                
    // TODO: 在此处添加构造函数逻辑
                
    //
            }

            
    /// <summary>
            
    /// 显示消息提示对话框
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="msg">提示信息</param>
            public static void Alert(System.Web.UI.Page page, string msg)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), 
    "message""<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
            }

            
    /// <summary>
            
    /// 显示消息提示对话框
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="msg">提示信息</param>
            public static void Show(System.Web.UI.Page page, string msg)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), 
    "message""<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
            }

            
    /// <summary>
            
    /// 控件点击 消息确认提示框
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="msg">提示信息</param>
            public static void ShowConfirm(System.Web.UI.WebControls.WebControl Control, string msg)
            {
                Control.Attributes.Add(
    "onclick""return confirm('" + msg + "');");
            }

            
    /// <summary>
            
    /// 显示消息提示对话框,并进行页面跳转
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="msg">提示信息</param>
            
    /// <param name="url">跳转的目标URL</param>
            public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url)
            {
                StringBuilder Builder 
    = new StringBuilder();
                Builder.Append(
    "<script language='javascript' defer>");
                Builder.AppendFormat(
    "alert('{0}');", msg);
                Builder.AppendFormat(
    "top.location.href='{0}'", url);
                Builder.Append(
    "</script>");
                page.ClientScript.RegisterStartupScript(page.GetType(), 
    "message", Builder.ToString());
            }
            
    /// <summary>
            
    /// 进行页面跳转
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="url">跳转的目标URL</param>
            public static void Redirect(System.Web.UI.Page page, string url)
            {
                StringBuilder Builder 
    = new StringBuilder();
                Builder.Append(
    "<script language='javascript' defer>");
                Builder.AppendFormat(
    "top.location.href='{0}'", url);
                Builder.Append(
    "</script>");
                page.ClientScript.RegisterStartupScript(page.GetType(), 
    "message", Builder.ToString());

            }


            
    /// <summary>
            
    /// 输出自定义脚本信息
            
    /// </summary>
            
    /// <param name="page">当前页面指针,一般为this</param>
            
    /// <param name="script">输出脚本</param>
            public static void ResponseScript(System.Web.UI.Page page, string script)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), 
    "message""<script language='javascript' defer>alert('" + script + "');</script>");
            }
        }


  • 相关阅读:
    浅析Java CompletionService
    经验总结13--EF配置
    消息摘要算法-HMAC算法
    03012_预处理对象executeQuery方法(实现数据库的查询)
    GO学习笔记:函数defer
    GO学习笔记:函数传值与传指针
    GO学习笔记:函数作为值、类型
    GO学习笔记:函数Panic和Recover
    GO学习笔记:import
    GO学习笔记:struct类型
  • 原文地址:https://www.cnblogs.com/chenqingwei/p/1749933.html
Copyright © 2020-2023  润新知