A newer version of this page is available. Switch to the current version.

Client-Side Commands

  • 2 minutes to read

ASPxHtmlEditor functionality is implemented through internal commands. Each time an end-user interacts with the control by clicking toolbar items, using hotkeys, typing, etc., one of default commands is invoked. Most of these commands can also be executed programmatically by the ASPxClientHtmlEditor.ExecuteCommand client method. Internal commands that can be executed manually are listed in the ASPxClientCommandConsts class.

It’s also possible to execute a custom client command in the same way. In this case, it’s necessary to pass the command name that doesn’t match any of aforementioned default commands to the ASPxClientHtmlEditor.ExecuteCommand method and handle the ASPxClientHtmlEditor.CommandExecuted event to perform required actions.


The following example demonstrates how to create custom toolbar items - Delete All and Add Smile.

The Delete All button click performs the following.

<dx:ASPxHtmlEditor ID="ASPxHtmlEditor1" runat="server">
                <dx:CustomToolbarButton CommandName="delete_all" 
                    Text="Delete All">
                <dx:CustomToolbarButton CommandName="add_smile" 
                    <Image Height="13px" Url="~/Images/smile-button.png" 
    <ClientSideEvents CustomCommand="function(s, e) {
        var imgHtml = '&lt;img src=&quot;Images/smile.png&quot;&gt;';
        switch (e.commandName){
            case 'delete_all':
                s.ExecuteCommand(ASPxClientCommandConsts.SELECT_ALL, null);
                s.ExecuteCommand(ASPxClientCommandConsts.PASTEHTML_COMMAND, '&nbsp;');
            case 'add_smile':
                s.ExecuteCommand(ASPxClientCommandConsts.PASTEHTML_COMMAND, imgHtml);
    }" />
See Also