• lhgdialog消息弹出框封装类


    lhgdialog消息弹出框的js很好用,但是不支持服务器控件,是因为服务器控件点击会刷新页面,所以搞了一个类

    首先引入js文件

    <script src="Scripts/lhgdialog/lhgcore.lhgdialog.min.js" type="text/javascript"></script>

    代码如下:

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Text;
    using System.Web.UI;
    namespace JboxDemo
    {
        public class MessageBox : System.Web.UI.Page
        {
            /// <summary>
            /// 弹出消息框(没有最大化和最小化)
            /// </summary>
            /// <param name="page">一般为this.page</param>
            /// <param name="title">弹出框标题</param>
            /// <param name="context">弹出框内容</param>
            public static void showinfo(Page page,string title,string context)
            {
    
                StringBuilder msg = new StringBuilder();
                msg.Append("<script type=\"text/javascript\">");
                msg.Append(" $(function () {$.dialog({lock: true,title: '"+title+"',content: '"+context+"',max:false,min:false,fixed: true,});});");
                msg.Append("</script>");
                page.ClientScript.RegisterStartupScript(page.GetType(),"msg",msg.ToString());
            }
            /// <summary>
            /// 创建一个右下角浮动的消息窗口
            /// </summary>
            /// <param name="page">一般为this.page</param>
            /// <param name="title">标题</param>
            /// <param name="context">内容</param>
            /// <param name="width">弹出框的宽度</param>
            /// <param name="height">弹出框的高度</param>
            public static void showSmallinfo(Page page, string title, string context, string width,string height)
            {
    
                StringBuilder msg = new StringBuilder();
                msg.Append("<script type=\"text/javascript\">");
                msg.Append(" $(function () {$.dialog({id: 'msg',title: '" + title + "',content: '" + context + "'," + width + ",height:" + height + ",left: '100%',top: '100%',fixed: true,drag: false,resize: false});});");
                msg.Append("</script>");
                page.ClientScript.RegisterStartupScript(page.GetType(), "msg", msg.ToString());
            }
            /// <summary>
            /// 弹出一个指定大小的层
            /// </summary>
            /// <param name="page">一般为this.page</param>
            /// <param name="title">标题</param>
            /// <param name="context">内容(可以为url:www.baidu.com)</param>
            /// <param name="width">弹出框的宽度</param>
            /// <param name="height">弹出框的高度</param>
            public static void shownewbox(Page page, string title, string context, string width, string height)
            {
    
                StringBuilder msg = new StringBuilder();
                msg.Append("<script type=\"text/javascript\">");
                msg.Append(" $(function () {$.dialog({title: '" + title + "',content: '" + context + "'," + width + ",height:" + height + ",fixed: true});});");
                msg.Append("</script>");
                page.ClientScript.RegisterStartupScript(page.GetType(), "msg", msg.ToString());
            }
        }
    }
    

      这样可以直接调用了

  • 相关阅读:
    预备作业02 : 体会做中学(Learning By Doing)
    7-1 货币转换
    秋季学校总结
    人生路上对我影响最大的三个老师
    自我介绍
    2019寒假作业3(抓老鼠啊~亏了还是赚了?)编程总结
    人生路上对我影响最大的三位老师
    自我介绍
    秋季学期学习总结
    7-1 抓老鼠啊~亏了还是赚了?
  • 原文地址:https://www.cnblogs.com/Jiangliang/p/3040700.html
Copyright © 2020-2023  润新知