ueditor 百度编辑器详细配置之asp.net版

1.下载百度编辑器的插件登录官网  https://ueditor.baidu.com/website/download.html

【下载】-【asp.net】-【UTF-8版】

ueditor 百度编辑器详细配置之asp.net版

2.把ueditor插件引入项目中

把文件夹放入你建设的工程文件中如图

ueditor 百度编辑器详细配置之asp.net版

3.实例化编辑器

实例化便签

<textarea id=”txtArticlecolText” name=”txtArticlecolText” class=”form-control” rows=”6″ ></textarea>

引入的js

 <link href=”/Content/Scripts/umeditor1_2_2-utf8-net/themes/default/css/umeditor.css” type=”text/css” rel=”stylesheet”>

<script type=”text/javascript” src=”/Content/Scripts/umeditor1_2_2-utf8-net/third-party/jquery.min.js”></script>

<script type=”text/javascript” charset=”utf-8″ src=”/Content/Scripts/umeditor1_2_2-utf8-net/umeditor.config.js”></script>

<script type=”text/javascript” charset=”utf-8″ src=”/Content/Scripts/umeditor1_2_2-utf8-net/umeditor.min.js”></script>

<script src=”/Content/Scripts/umeditor1_2_2-utf8-net/lang/zh-cn/zh-cn.js”>

实例化

var um = UM.getEditor(‘txtArticlecolText’);

配置上传图片

后台上传图片方法

        public void ProcessRequest()

        {

           this.HttpContext.Response.ContentEncoding = System.Text.Encoding.UTF8;

            //上传配置

            string pathbase = “/Upload/Article/”;                                                          //保存路径

            int size = 10;                     //文件大小限制,单位mb                                                                                   //文件大小限制,单位KB

            string[] filetype = { “.gif”, “.png”, “.jpg”, “.jpeg”, “.bmp” };                    //文件允许格式

            string callback = this.HttpContext.Request[“callback”];

            string editorId = this.HttpContext.Request[“editorid”];

            //上传图片

            Hashtable info;

            Uploader up = new Uploader();

            info = up.upFile(this.HttpContext, pathbase, filetype, size); //获取上传状态

            string json = BuildJson(info);

            this.HttpContext.Response.ContentType = “text/html”;

            if (callback != null)

            {

                this.HttpContext.Response.Write(String.Format(“<script>{0}(JSON.parse(\”{1}\”));</script>”, callback, json));

            }

            else

            {

                this.HttpContext.Response.Write(json);

            }

        }

        private string BuildJson(Hashtable info)

        {

            List<string> fields = new List<string>();

            string[] keys = new string[] { “originalName”, “name”, “url”, “size”, “state”, “type” };

            for (int i = 0; i < keys.Length; i++)

            {

                fields.Add(String.Format(“\”{0}\”: \”{1}\””, keys[i], info[keys[i]]));

            }

            return “{” + String.Join(“,”, fields) + “}”;

        }

更多技术请关注

项目集成软件工程师

ueditor 百度编辑器详细配置之asp.net版》来自互联网,仅为收藏学习,如侵权请联系删除。本文URL:http://www.hashtobe.com/677.html