RadEditor for ASP.NET

CSS Styles Send comments on this topic.
See Also
DropDowns > CSS Styles

Glossary Item Box

 

The CSS class dropdown of Telerik RadEditor displays all classes defined in the page or in the external CSS file by default. You can easily modify this default set and display only a few classes using the Add method of CssClasses Collection.

e.g.

ASPX Copy Code
<style>
a.link
{
  color: #0000ff;
  font-weight: normal;
  font-style: italic;
}
.img
{
  border: none;
}
</style>
...
<rad:RadEditor id="RadEditor1" Runat="server"></rad:RadEditor>  

 

C# Copy Code
RadEditor1.CssClasses.Add("Links class ", "a.link");
RadEditor1.CssClasses.Add(
"Images class ", ".img");

 

VB.NET Copy Code
RadEditor1.CssClasses.Add("Links class ", "a.link")
RadEditor1.CssClasses.Add("Images class ", ".img")

Please, note that you can add one CSS class at a time.

Make sure you specify the exact name of the class (i.e. "a.link" - not "a" or "link"; ".img" - not "img").

When using the Add method the CSS class dropdown will be reset, so the ones you add will create a new CSS class set. See the example below:

 

Default state

Programmatic population

(The CSS class dropdown contains
all existing classes)

(The CSS class dropdown contains
only the classes added using
the Add method)

 

You can also populate the CSS class dropdown using the ToolsFile, as shown in the example below:

ToolsFile.xml Copy Code
<classes>
  
<class name="Links class" value="a.link" />
  
<class name="Images class" value=".img" />
</
classes>

 

Please, bear in mind that the RadEditor will persist its state (including the CSS classes set) between postbacks.
In order to create a new set of CSS classes (e.g. for different users), you will need to clear it first.
This can be done using Remove method of CssClasses Collection.


Warnings:

Please, note that if you have css classes defined with the following syntax:

.Emphasis, p em{color: #A4CE3A; font-style: normal; }

then the editor will parse and read only the .Emphasis class and will populate the "Apply Class" dropdown only with this class. If RadEditor starts to parse the strings after the comma, this will drastically decrease the editor performance and it will be loaded slower on the page.

 

If your page does not contain any css classes and you try set an item in the dropdown with the CssClasses.Add syntax, e.g.

RadEditor1.CssClasses.Add("Links class ", "a.link")

then the item will be not populated, because the a.link will not exist on the page.

 

See Also