How to: Create custom toolbar items
This example demonstrates how to create a custom toolbar with different types of custom toolbar items in the ASPxHtmlEditor.
A toolbar item’s CommandName property specifies the name of the command that is executed by this item. The custom command logic is implemented in the ASPxClientHtmlEditor.CustomCommand event handler.
function OnCommandExecute(s, e) {
var value = e.parameter;
switch (e.commandName) {
case "InsertTemplate":
InsertTemplate(value);
break;
case "InsertSmiley":
InsertSmiley(value);
break;
case "InsertCustomer":
InsertCustomer(value);
break;
case "DeleteAll":
s.SetHtml(' ');
break;
}
}
function InsertTemplate(value) {
HtmlEditor.GetSelection().SetHtml(value + " ");
}
function InsertSmiley(value) {
var selection = HtmlEditor.GetSelection();
var valueInfo = value.split("#");
selection.SetHtml("<img style='margin-bottom:-2px;' src='../Content/Smilies/" + valueInfo[0] + ".png' alt='" + valueInfo[2] + "' title='" + valueInfo[1] + "' />");
}
function InsertCustomer(value) {
HtmlEditor.GetSelection().SetHtml(value);
}