There is an arrow button right to the insert template button. When users click this arrow button, the code snippet treeview will display. The code snippet is a convenient tool for displaying a predefined set of code snippets. You can create a code snippet treeview programmatically or by modifying the richtexteditor\config\statictemplates.xml.

How to disable code snippets treeview?

If you want to disable the code snippets treeview, you can set Editor.DisableStaticTemplates Property to true.

<RTE:Editor runat="server" ID="Editor1" DisableStaticTemplates="true" />

Add custom code snippets by editing the statictemplates.xml file

The statictemplates.xml file can be found in the richtexteditor/config folder. In statictemplates.xml file you can find the following code which defines the code snippets information within RichTextEditor.

Programmatically add code snippets

RichTextEditor provides a few powerful properties that allow you programmatically manage the custom code snippets.

Property Description
Editor.TemplateGroupArray
An array of code snippets groups which will be displayed in code snippets treeview as treenode.
Editor.TemplateItemArray
An array of predefined code snippets which will be displayed in code snippets treeview as treeitem.

Example:

RTEDataItem[] dis = new RTEDataItem[1];
RTEDataItem item = new RTEDataItem();
item.Text = "Template Title 1";
item.Code = "<div style=\"color:blue;\">RichTextEditor code snippets demo</div>";
item.Href = "";
dis[0] = item;
Editor.TemplateItemArray = dis;
Editor.TemplateUrlArray
An array of xml files. Those xml files should contain predefined set of code snippets which will be displayed in the code snippets treeview. editor.TemplateUrlArray = new string[] { "mysnippets.xml"};

Send feedback about this topic to CuteSoft. © 2003 - 2014 CuteSoft Components Inc. All rights reserved.