<%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %> Attaching Events — CKEditor for ASP.NET Sample

CKEditor for ASP.NET Sample — Attaching Events

In order to attach a function to an event in a single editor instance, use the following method:

CKEditor1.CKEditorInstanceEventHandler = new System.Collections.Generic.List<object>();
CKEditor1.CKEditorInstanceEventHandler.Add(new object[] { "instanceReady"
	, "function (evt) { alert('Event Handler attached on CKEditorInstanceEventHandlerto editor: ' + evt.editor.name);}" });

Attaching a function to an event in all editor instances (use e.g. in Global.asax) can be achieved in the following way:

CKEditor.NET.CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler.Add(new object[] 
	{ "mode", function (evt) { alert('Events attached to all instances. (Events: \"mode\")');}" });

To attach a function to CKEditor events, use the following code:

CKEditor1.CKEditorEventHandler.Add(new object[] { "instanceReady"
	, "function (evt) { alert('Events attached to CKEditor. (Events: \"instanceReady\")');}" });

The sample editor below uses the first method to attach a function to an event in this instance only.

<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>