This blog post contains outdated information.
The cited code snippets may be workarounds, and be part of the official API in the meantime.
TextControl.Web: Inserting Merge Fields Using Javascript
In a recent post, we already introduced the hidden Javascript interface that is available in version X12. This interface gives you access to the majority of internal Javascript calls that are used in TextControl.Web. This interface is hidden by default, because it is still in beta and undocumented. In order to enable the hidden interface, the function enableCommands() must be called. TXTextControl.enableCommands(); The following code inserts a merge field with a specific name into the…

In a recent post, we already introduced the hidden Javascript interface that is available in version X12. This interface gives you access to the majority of internal Javascript calls that are used in TextControl.Web. This interface is hidden by default, because it is still in beta and undocumented.
In order to enable the hidden interface, the function enableCommands() must be called.
TXTextControl.enableCommands();
The following code inserts a merge field with a specific name into the currently active TextPart (Header, Footer, MainText or TextFrame).
function insertField(name) {
var mergeField = {
Name: name,
Text: "«" + name + "»"
};
TXTextControl.sendCommand(
TXTextControl.Command.InsertItem,
TXTextControl.ItemType.FieldAdapter,
TXTextControl.FieldType.MergeField,
0, mergeField);
}
The following call inserts a MergeField with the name fieldname at the current input position:
TXTextControl.enableCommands();
insertField(\'fieldname\');
Stay tuned to learn more about the hidden JS interface.
Related Posts
ASP.NETJavaScriptDocument Editor
Detect Toggle Button Changes Using a MutationObserver
This article shows how to detect changes of toggle buttons in the ribbon of the web editor using a MutationObserver. The state of a toggle button in the ribbon visualizes the state of a certain…
TextControl.Web: Determine when a Document Has Been Completely Loaded
Web.TextControl provides an event that can be used to determine when the ribbon bar has been loaded completely in order to add and remove ribbon items such as groups, tabs and buttons. But when…
TextControl.Web: Adding Custom Ribbon Tabs
In recent blog entries, we explained how to add custom buttons or ribbon groups to the ribbon bar. This article shows how to add complete ribbon tabs to the existing ribbon bar of Web.TextControl.…
Building a Touch-enabled Button Bar with Javascript
A ribbon bar is a user-friendly interface for desktop environments when users can utilize a mouse to navigate. On tablets or smart-phones, another, more touch-enabled, interface might be required.…
Create a Table of Contents in Windows Forms using C#
This article explains how to create a table of contents in Windows Forms using the ribbon or programmatically. Creating a table of contents is required to organize large documents.