码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-11-12 07:41:55      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:百度   隐藏   targe   var   版本   ued   onclick   orm   .config   

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

这里使用百度编辑器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;
        }
    }

  

 

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

标签:百度   隐藏   targe   var   版本   ued   onclick   orm   .config   

原文地址:http://www.cnblogs.com/LoveTX/p/6056084.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!