1

我已将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);
    }

我在这里做错了什么?

4

1 回答 1

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"} };

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

于 2013-02-23T02:43:49.070 回答