ASP.NET获取不到Kindeditor的内容解决方法

<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script>
    KindEditor.ready(function (K) {
        var editor1 = K.create('#outlookcontent_outsidecontent_leftcontent_text', {
            cssPath: '../editor/plugins/code/prettify.css',
            uploadJson: '../editor/asp.net/upload_json.ashx',
            fileManagerJson: '../editor/asp.net/file_manager_json.ashx',
            allowFileManager: true,
            afterCreate: function () {
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>


... ... ... ...

<textarea id="text" runat="server" style=" width:100%" cols="30" rows="20"></textarea>


我用了两层母版页,结果是能显示kindeditor并且textarea可以从数据库获取值并显示

但是在textarea中输入的值却不能保存

在非母版页中没有这个问题,后来网上搜索和几篇文章发现了解决方法:

KindEditor.ready(function (K) {
        var editor1 = K.create('#outlookcontent_outsidecontent_leftcontent_text', {
            cssPath: '../editor/plugins/code/prettify.css',
            uploadJson: '../editor/asp.net/upload_json.ashx',
            fileManagerJson: '../editor/asp.net/file_manager_json.ashx',
            allowFileManager: true,
            afterBlur:function(){this.sync();},
            afterCreate: function () {
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
            }

afterblur是说失去焦点之后将kindeditor的值同步给textarea

加上这句之后我测试可以通过了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值