主题: .net怎么在母版页下无法显示。
作者: 某白, 发布日期: 2013-05-15 21:32:43, 浏览数: 2311
单独页无问题。嵌套母版页就出问题。最简单的母版页。啥都不加也有问题。费解。
作者: 安静燊, 发布日期: 2014-06-13 20:46:50

之前我也是和你同样的问题

下面是我的代码

<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

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

回复
发表新帖 发表回复