CKEditor:在页面中定义配置

时间:2015-06-11 20:33:52

标签: javascript asp.net ckeditor

我有一个带有以下CKEditor的ASP.net用户控件

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<CKEditor:CKEditorControl ID="txtHtmlText" BasePath="~/Scripts/ckeditor/" 
        Toolbar="Bold|Italic|Underline|Strike|Subscript|Superscript|-    |TextColor|BGColor|Font|FontSize
JustifyLeft|JustifyCenter|JustifyRight|Justify|-|Outdent|Indent|-    |NumberedList|BulletedList
Cut|Copy|Paste|PasteText|PasteFromWord|-|HorizontalRule|Link|Unlink|-    |Source|About"runat="server"></CKEditor:CKEditorControl>

我试图覆盖CKEditor的config.js中定义的字数限制。我在.ascx文件中使用了以下代码并获得了错误

&#34;未捕获的ReferenceError:CKEDITOR未定义&#34;。请帮忙

<script type="text/javascript">

    CKEDITOR.replace('txtHtmlText',
{
    wordcount: {
        // Whether or not you want to show the Paragraphs Count
        showParagraphs: false,

        // Whether or not you want to show the Word Count
        showWordCount: false,

        // Whether or not you want to show the Char Count
        showCharCount: true,

        // Whether or not you want to count Spaces as Chars
        countSpacesAsChars: false,

        // Whether or not to include Html chars in the Char Count
        countHTML: false,

        // Maximum allowed Word Count, -1 is default for unlimited
        maxWordCount: 500,

        // Maximum allowed Char Count, -1 is default for unlimited
        maxCharCount: 500
    }
});
</script>

2 个答案:

答案 0 :(得分:0)

我今天尝试了我的要求,并且我能够成功添加该功能。

如果我会在你的位置,我会检查几件事

  1. 是否添加了对CKEditor的引用(我知道它很明显)
  2. 添加extraPlugins:'wordcount',就在wordcount之上:{
  3. 检查开发者控制台是否有任何进一步调查。
  4. 此链接帮助我解决了我的问题@ https://github.com/w8tcha/CKEditor-WordCount-Plugin/blob/master/wordcount/samples/wordcountWithMaxCount.html

答案 1 :(得分:0)

@Vinayak Prabha,

按照维克拉姆的建议尝试。不过问题呢?

CKEditor ID“txtHtmlText”是服务器ID,如果必须在java脚本中使用,则应使用客户端ID。

试试这个

  

var ckEditorClientID =“#&lt;%= txtHtmlText.ClientID%&gt;”;

     

CKEDITOR.replace(ckEditorClientID,