Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Getting Started
   [Collapse]Concepts
     ASPxRichEdit Control
    [Expand]Document
     Supported Document Formats
     Import and Export
     Formatting Characters
     Formatting Paragraphs
    [Expand]Fields
     Mail Merge
     Restrictions
     Spell Checking
    [Collapse]Client API
      Document Model Information
      Client Selection
      Client Commands
    [Expand]Built-in Dialogs
     Adaptivity
     HTML Tag Interpretation
     Keyboard Shortcuts
   [Expand]Examples
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Client Commands

Available commands are a powerful tool for manipulating document content on the client in code. Most commands replicate the RichEdit's default UI commands available through the editor's ribbon. These commands are useful when you are required to implement a custom toolbar for the RichEdit instead of the default built-in ribbon. For an example of such a custom toolbar, refer to the Rich Text Editor - Custom Toolbar via Client API demo.

The client RichEdit ASPxClientRichEdit.commands property is an entry point to all available client commands. All commands are implemented as individual (command type related) objects inherited from the CommandBase. Command objects are exposed through the properties of the RichEditCommands object returned by the RichEdit's ASPxClientRichEdit.commands property. In code, a command can be accessed in the following notation.
[clientRichEditName].commands.[commandName]

Each command object exposes the execute and getState methods. The execute method may result in no action taken if a command's state obtained using the getState method does not allow command execution (for instance, in a case when a command is not enabled in the ribbon).

  • The execute method

    This is the command's main method. It accomplishes the task for which the command is implemented. For its execution, a command may require additional data to be passed as the execute method's parameter. See the signature of each command's execute method for details.

  • The getState method

    This method is called automatically before command execution. The method's return value is a command type specific object (CommandState<T>) that can contain the following state-related settings.

    • enabled (SimpleCommandState.enabled)
      Gets a value indicating whether the command's UI element is enabled (within the ribbon and context menu).
      If set to false, a command cannot be executed; the command's execute method will return false.

    • visible (SimpleCommandState.visible)
      Gets a value indicating whether the command's UI element is visible.

    • value (CommandState<T>.value)
      Gets the command state value.


There are specificities in using commands to define certain elements (such as fonts or shortcuts). These specificities are described in the following sections.

Expanded Working with Fonts

When you format fonts and need to specify the font size value (which is measured in points), use an integer number or a fractional number representing half font sizes (such as 11, 11.5, 12, 12.5 and etc.). Use the ASPxClientRichEdit.unitConverter to convert size measure units (inches, twips, pixels, centimeters) to points.

Expanded Working with Sizes

When you modify a size value in the document model (e.g., page size or margin size), assign these values in twips. Use the ASPxClientRichEdit.unitConverter to convert other size measure units (inches, points, pixels, centimeters) to twips.

Expanded Working with Client Events

The client commands that change the document's content (or its selection) trigger the corresponding client-side events as well as changes made through the RichEdit's UI. Set the ASPxRichEditBehaviorSettings.RaiseClientEventsOnModificationsViaAPI property to false, if you need to ignore client commands calls, when you handle the client-side events.

Expanded Working with Shortcuts

To define a shortcut, use the RichEditCommands.assignShortcut command whose AssignShortcutCommand.execute methods accepts two parameters - keyCode and callback.

  • keyCode
    A specifically generated code that uniquely identifies the combination of keys specified for a shortcut. This code is specified using the ASPxClientUtils.GetShortcutCode method.

  • callback
    A callback function to execute when a shortcut is activated.

The following code demonstrates how to define a shortcut that updates a document field on pressing the "u" key.

Is this topic helpful?​​​​​​​