aspnet-js-richeditcommands-e3cb4ede.md
Gets a command to add a field at the current position in a document.
get createField(): CreateFieldCommand
| Type | Description |
|---|---|
| CreateFieldCommand |
An object that provides methods that execute the command and check its state.
|
Call the execute method to invoke the command. The method checks the command state (obtained via the getState method) to determine whether the action can be performed.
You can execute the command without parameters or with an optional code parameter depending on your requirements:
Usage examples:
//example 1
richEdit.commands.createField.execute();
//example 2
richEdit.commands.createField.execute("TOC \\h \\c \"Figure\"");
//example 3
richEdit.commands.createField.execute();
richEdit.commands.insertText.execute("Date");
richEdit.commands.updateField.execute();
//example 4
var fieldCode = "Date";
richEdit.commands.insertText.execute(fieldCode);
richEdit.selection.intervals = [new ASPx.Interval(rich.selection.intervals[0].start - fieldCode.length, fieldCode.length)];
richEdit.commands.createField.execute();
richEdit.commands.updateField.execute();
Refer to the following section for more information: Client Commands.
See Also