In the DevExpress ASP.NET MVC Rich Text Editor (RichEdit extension), document fields are special placeholders for non-static data that might change (be updated on field update). These placeholders are replaced with actual data when the document is rendered for display or print. Using fields, you can automate different aspects of your document, such as auto page numbering, inserting actual dates and times, etc. The default Mail Merge ribbon tab can be used to work with fields (create, update, switch between field display modes).
A field is specified by a field code, and can be viewed within a document as either a field code or a field result. The field code specifies how the field result should be calculated when the field is updated. The field result represents the actual, resultant value of the field. This value is calculated by the RichEdit's field updating engine based on the field code information. To insert a field, position the mouse cursor within a document and execute the Create Field command from the ribbon's Mail Merge tab (or use the Ctrl + F9 shortcut). Field codes appear between curly brackets ( { } ). The following field codes are supported.
- DATE - Inserts the current date and time.
- TIME - Inserts the current time.
- DOCVARIABLE - Enables you to programmatically insert complex content when this field is updated.
- HYPERLINK - Enables you to navigate to another location or to a bookmark.
- NUMPAGES - Inserts the total number of pages.
- PAGE - Inserts the number of the page containing the field.
- MERGEFIELD - Retrieves a value from the bound data source.
In a document, a field code is displayed using the following syntax:
{ FIELDNAME Properties Optional_Switches }
FIELDNAME - This is the name of the field.
Properties - These are any instructions or variables that are used in a particular field. Not all fields have parameters, and in some fields, parameters are optional.
Optional switches - These are any optional settings that are available for a particular field. Not all fields have switches available, other than those that control the formatting of the field results.
You can switch between displaying the field code and the field result by right-clicking in a field (or in a selected document portion that contains fields) and clicking the context menu's Toggle Field Codes item (or using the Shift + F9 shortcut). To toggle all fields within a document, use the Show All Field Codes and Show All Field Results commands in the ribbon's Mail Merge tab (or use the Alt + F9 shortcut).
To update fields, use the context menu's Update Field item (or press F9). All fields in a document can be updated using the Update All Fields command in the ribbon's Mail Merge tab.
Local Copy of this Demo To inspect the source code for this demo on your machine, you must first install our components via the DevExpress Component Installer. |
You can open a local copy of this online demo directly from this webpage (if using v20.2.8, 21.1.4 or higher).
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\MVCxRichEditDemos |