To enable the template management function of the RichTextEditor control, you must set up a managed template folder.

This is simply a folder in which you will be placing templates for your users to use in their content. Create a folder in your application's root folder. (For most applications, this is your web server's root folder, or the folder where your Visual Studio .NET project file is located.) The folder can be named something like "/uploads/", "/templates" or "/UserTemplate". Use "~/" (tilde) as a substitution of the web-application root directory.

Make sure that the MACHINE/ASPNET user has Read+Write permissions on this folder and its contents.

How to specify the template path?

You can easily specify the template path using the following methods:

Edit security policy file

The security policy file (default.config, admin.config and guest.config) can be found in the richtexteditor/config folder. In security policy file you can find the following code which defines the template path information within RichTextEditor. By default, insert template dialog has the following settings:


<category for="Template"><!-- Insert Template Dialog -->  
       <security name="Extensions">*.txt,*.doc,*.pdf,*.zip,*.rar,*.htm,*.xls,*.html,*.rtf</security>
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Template Files</security><!-- storage display name -->
       </storage>
</category>

If you want to add new folders as template path, you need to create new storages and specify the storgae ID, name, path.

<category for="Template">
       <storage id="newtemplatepath>
              <security name="StorageName">New Template</security><!-- storage display name -->
              <security name="StoragePath">~/newtemplatepath</security>
       </storage>
       <storage id="newtemplatepath2>
              <security name="StorageName">New Template2</security><!-- storage display name -->
              <security name="StoragePath">~/newtemplatepath2</security>
       </storage>
</category>

Programmatically specify the template path

RichTextEditor provides a powerful method named Editor.SetSecurity that allows you programmatically manage the security settings.

1. Set template path using the default storage

Editor1.SetSecurity("Template", "default", "StoragePath", "~/uploads"); 
Editor1.SetSecurity("Template", "default", "StorageName", "Uploads");

This is equivalent to the following code:

<category for="Template"><!-- Template Dialog -->  
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Template Files</security><!-- storage display name -->
       </storage>
</category>

2. Create a new storage for insert template dialog and specify the ID, name and path

Editor1.SetSecurity("Template", "newtemplatepath", "StoragePath", "~/newtemplatepath"); 
Editor1.SetSecurity("Template", "newtemplatepath ", "StorageName", "New Template");

This is equivalent to the following code:

<category for="Template">
       <storage id="newtemplatepath>
              <security name="StorageName">New Template</security>
              <security name="StoragePath">~/newtemplatepath</security>
       </storage>
</category>

3. To programmatically disable a storage access, you can use the following method:

Editor1.SetSecurity("Template", "newtemplatepath", "AllowAccess", "false"); 

In the above code, insert template dialog access to a storage is disabled. The storage ID in the above code is "newtemplatepath".


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