The Paragraph style dropdown of Telerik RadEditor displays a predefined set of styles by default. This set is defined by the Paragraphs collection. You can easily modify this default set and display only a few styles using the Add method for this Collection:
| ASPX/ASCX |
Copy Code |
|
<rad:RadEditor Id="RadEditor1" Runat="server"></rad:RadEditor> |
| C# |
Copy Code |
|
//Provide an option for clearing the style formatting RadEditor1.Paragraphs.Add("Clear Formatting", "<body>");
RadEditor1.Paragraphs.Add("Heading 1", "<h1>"); RadEditor1.Paragraphs.Add("Heading 2", "<h2>"); RadEditor1.Paragraphs.Add("Heading 3", "<h3>"); |
| VB.NET |
Copy Code |
|
RadEditor1.Paragraphs.Add("Clear Formatting", "<body>")
RadEditor1.Paragraphs.Add("Heading 1", "<h1>") RadEditor1.Paragraphs.Add("Heading 2", "<h2>") RadEditor1.Paragraphs.Add("Heading 3", "<h3>")
|
Please, note that you can add one Paragraph style at a time.
When using the Add method the Paragraph style dropdown will be reset, so the ones you add will create a new Paragraph style set. See the example below:
|
Default state |
Programmatic population |
 |
 |
|
(The Paragraph style dropdown contains the default set of styles) |
(The Paragraph style dropdown contains only the styles added using the Add method) |
RadEditor also supports block format with the CSS class set:
| ASPX |
Copy Code |
|
<style> .colored {color: red;} </style> ... <rad:RadEditor id="RadEditor1" Runat="server"></rad:RadEditor> |
| C# |
Copy Code |
|
RadEditor1.Paragraphs.Add("Heading 2 Bordered", "<h2 class=\"colored\">"); |
| VB.NET |
Copy Code |
|
RadEditor1.Paragraphs.Add("Heading 2 Bordered", "<h2 class='colored'>") |
You can also populate the Paragraph dropdown using the ToolsFile.xml, as shown in the example below (using default and custom class styles):
ToolsFile.xml:
<paragraphs>
<paragraph name="<H1>Heading 1</H1>" value="<H1>" />
<paragraph name="<H2>Heading 2</H2>" value="<H2>" />
<paragraph name="<H3>Heading 3</H3>" value="<H3>" />
</paragraphs>
Here is how the FormatBlock dropdown will look, when populated with the XML code above:

To add a style do the following:
<paragraph name="<p class='redStyle'>redStyle</p>" value="<p class='redStyle'>" />
See Also