之前我也是和你同样的问题
下面是我的代码
<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
加上这句之后我测试可以通过了