• King 文编编辑器的使用


    首先,需要引入三个JS 包

        <script src="../../Content/jquery.11.3.min.js"></script>
        <script src="../../kindeditor-4.1.7/kindeditor-min.js"></script>
        <script src="../../Content/artDialog/artDialog.function.js"></script>
    View Code

    然后,就是King文本编辑器的script 代码

     <script type="text/javascript">
            @*父文本框的使用*@
            var editor;
            KindEditor.ready(function (K) {
                //实现显示富文本的代码,第一个方法,实现添加的框架
                editor = K.create('#TxtMainContent', {
                    resizeType: 1,
                    allowPreviewEmoticons: false,
                    allowImageUpload: false,
                    filterMode: true,
                    items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                        'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                        'insertunorderedlist', '|', 'emoticons'],
                    allowFileManager: true,
                });
                //不知道什么用处,暂时添加在这里
                prettyPrint();
            });
            //实现操作Jquery的方法
            $(function () {
                //实现添加新闻的信息
                $("#btnAddMain").click(function () {
                   
                    var co = editor.html();
                    $.ajax({
                        url: "/MainDetail/AddMain",
                        data: {
                            TxtMainTitle: "12131232",
                            TxtMainDateTime: $("#txtMainDateTime").val(),
                            TxtMainPeople: $("#txtMainPeople").val(),
                            TxtMainContent: encodeURIComponent(co)
                        },
                        type: "post",
                        success: function (data) {
                            if (data == 0) {
                                alert("添加成功,正在跳转中");
    
                            }
                            else {
                                alert("添加失败,请您检查");
                            }
                        }
    
                    })
                });
            });
        </script>
    View Code

    前台页面的最后一步就是写一个textarea 容器

        <td>
                            <textarea id="TxtMainContent" name="TxtMainContent" style=" 550px;
                                height: 300px; visibility: hidden;" runat="server"></textarea>
                        </td>
    View Code

    后台的写法

            /// <summary>
            /// 值做到加密传值,至于解密自己去看老师的百度富去!
            /// </summary>
            /// <param name="TxtMainTitle"></param>
            /// <param name="TxtMainContent"></param>
            /// <returns></returns>
            [HttpPost]
            public JsonResult AddMain(string TxtMainTitle, string TxtMainContent)
            {
    
                return Json(0);
            }
    View Code
    技在手,能在身,思在脑,大度看世界,从容过生活!!!
  • 相关阅读:
    用wamp配置的环境,想用CMD连接mysql怎么连
    Mysql删除表
    MySQL创建表
    Leetcode 130. Surrounded Regions
    Leetcode 111. Minimum Depth of Binary Tree
    Leetcode 110. Balanced Binary Tree
    Leetcode 98. Validate Binary Search Tree
    Leetcode 99. Recover Binary Search Tree
    Leetcode 108. Convert Sorted Array to Binary Search Tree
    Leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal
  • 原文地址:https://www.cnblogs.com/bsjbk/p/6991360.html
Copyright © 2020-2023  润新知