Hello,
Note that there should be an error thrown in the console which explains the possible reason for the described behavior -
ReferenceError: RadEditorCommandList is not defined.
The implementation of the custom command is added in the head tag of the document, which means that the script will be started before the rendering of the body element. Without a rendered body the RadEditor object is not yet initialized, which correspondingly means that the Command List does not exist.
I suggest placing the the script tag with the command implementation right after the RadEditor declaration or assuring that the same is triggered after the editor loading.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="EditorPage.aspx.vb" Inherits="EditorPage" %>
<%@ Register tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
runat
=
"server"
ID
=
"ScriptMngr"
>
</
asp:ScriptManager
>
<
telerik:RadEditor
runat
=
"server"
ID
=
"reWysiwyg"
ToolsFile
=
"~/FullSetOfTools.xml"
SkinID
=
"DefaultSetOfTools"
AutoResizeHeight
=
"true"
CssClass
=
"minwidth"
ContentAreaMode
=
"div"
>
<
ImageManager
ViewPaths
=
"~/images"
DeletePaths
=
"~/images"
UploadPaths
=
"~/images"
/>
</
telerik:RadEditor
>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
//
<![CDATA[
/* Implementation of the Custom command, declared in the editor's Tools.xml file! */
RadEditorCommandList["Custom"] = function (commandName, editor, args) {
var myCallbackFunction = function (sender, args) {
if (args.href != undefined) { editor.pasteHtml(String.format("<img src={0} /> ", args.href)) }
}
editor.showExternalDialog('../../Controls/Custom/UploadImage.aspx',
{},
500,
230,
myCallbackFunction,
null,
'Insert Image',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
false,
false);
};
/*TO DO: Implement something meaningful here*/
//]]>
</
script
>
</
div
>
</
form
>
</
body
>
</
html
>
Regards,
Ianko
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the
blog feed now.