I'm using CKEditor.Net in a asp.net (C#) Web Application Project. I need to insert some text into CKEditor cursor location, when a user clicks a server side button.
This is my code,
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);
}
CKEditor works fine, but I get this error when I click the button (to insert some text to curser locatin),
Error: 'CKEDITOR' is undefined
How to fix this?
Thanks in advance...