• Asp.Net使用百度编辑器(ueditor)


    1、  1.4.3以上版本将不再承诺支持ie6/ie7。

    2、如果是aspx 需要加上  ValidateRequest="false"

    3、Web.config

      <system.web> 
        <httpRuntime requestValidationMode="2.0" maxRequestLength="102400" />
      </system.web>
    

      

    这里使用百度编辑器1.4.3。包可移植官网下载。

    http://pan.baidu.com/s/1ntG3Tsl

    1、百度编辑器不依赖于 jquery

    2、使用服务器控件(runat="server")需要使用 服务器中转赋值内容

    如: HTML代码

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script src="ueditor1_4_3/ueditor.config.js"></script>
        <script src="ueditor1_4_3/ueditor.all.js"></script>
    </head>
    <body>
        <form runat="server">
            <!-- 加载编辑器的容器 -->
            <script id="editor" name="content" type="text/plain"> 
            </script>
            <!--隐藏控件为编辑器赋值用-->
            <asp:HiddenField ID="hide_Content" Value="" runat="server" />
            <asp:Button runat="server" ID="btn_Add" Text="增加" OnClick="btn_Add_Click" />
            <!--点击增加输出到这里-->
            <asp:Literal ID="ltMsg" runat="server"></asp:Literal>
        </form>
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var htmlContent = document.getElementById("<%=this.hide_Content.ClientID%>").value;
            //正确的初始化方式  阻止复制的div标签自动转换为p标签
            var ue = UE.getEditor('editor', { allowDivTransToP: false });  
            //正确的初始化方式
            ue.ready(function () {
                //this是当前创建的编辑器实例
                this.setContent(htmlContent)
            })
        </script>
    </body>
    </html>
    

      

    后台cs代码

      

     public partial class index_aspnet : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    //初始化赋值
                    hide_Content.Value = "首次赋值";
                }
            }
    
            protected void btn_Add_Click(object sender, EventArgs e)
            {
                string content = Request["content"];
                string editorValue = Request["editorValue"];//这个是ueditor.all.js 里面默认的值
                ltMsg.Text = hide_Content.Value = content;
            }
        }
    

      

     

  • 相关阅读:
    HTTP协议详解(转)
    Linux shell 提取文件名和目录名的一些方法(转)
    快速建立ssh互信(转)
    Python 连接mysql
    pt-online-schema-change原理解析(转)
    python基础学习笔记3
    python基础学习笔记2
    DNS服务器原理
    代理服务器(Proxy)原理
    Ext.MessageBox消息框
  • 原文地址:https://www.cnblogs.com/LoveTX/p/6056084.html
Copyright © 2020-2023  润新知