CKEditor未定义

时间:2013-02-23 02:36:16

标签: javascript asp.net ckeditor

我已将CKEditor.Net添加到我的ASP.NET Web应用程序项目中。当我尝试使用javascript插入文本时,它会出现此错误

Error: 'CKEDITOR' is undefined

这是我的代码,

HTML

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"    CodeBehind="Test.aspx.cs" Inherits="eLetters.Test" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        function insertText(text) {
            CKEDITOR.instances.insertText('text');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <CKEditor:CKEditorControl ID="CKEditor1" BasePath="/ckeditor/" runat="server"></CKEditor:CKEditorControl>
</asp:Content>

C#

    protected void Button1_Click(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(GetType(), "MyKey", "insertText('data');", true);
    }

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

尝试在标记中设置BasePath="~/ckeditor"

这是一个用于实例化工具栏的代码隐藏代码段:

CKEditor1.config.toolbar = new object[] 
{ 
    new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Cut", 
    "Copy", "Paste", "PasteText", "-", "NumberedList", "BulletedList", 
    "-", "Outdent", "Indent", "Blockquote", "-", "JustifyLeft", 
    "JustifyCenter", "JustifyRight", "JustifyBlock"} };

注释掉你的文字插入脚本,然后将其设置为开始; - )