CSS Class Dropdown Customization
The CSS Class dropdown of CuteEditor displays a predefined set of CSS Classes.
You can easily add your own CSS Classes using the following methods.
1. Programmatically populate the CSS Class dropdown:
C# Example:
- if (!IsPostBack) {
- CuteEditor.ToolControl toolctrl=Editor1.ToolControls["CssClass"];
- if(toolctrl!=null) {
- CuteEditor.RichDropDownList dropdown=(CuteEditor.RichDropDownList)toolctrl.Control;
-
- CuteEditor.RichListItem richitem=dropdown.Items[0];
-
- dropdown.Items.Clear();
-
- dropdown.Items.Add(richitem);
-
- dropdown.Items.Add("RedColor");
-
- dropdown.Items.Add("Highlight","Highlight");
-
- dropdown.Items.Add("<span class='BoldGreen'>Bold Green Text</span>","Bold Green Text","BoldGreen");
- }
- }
VB Example:
- If Not Page.IsPostBack Then
- If Not Editor1.ToolControls("CssClass") Is Nothing Then
- Dim dropdown As CuteEditor.RichDropDownList
- Dim richitem As CuteEditor.RichListItem
- dropdown = DirectCast(Editor1.ToolControls("CssClass").Control, CuteEditor.RichDropDownList)
-
- richitem = dropdown.Items(0)
-
- dropdown.Items.Clear()
-
- dropdown.Items.Add(richitem)
-
- dropdown.Items.Add("RedColor")
-
- dropdown.Items.Add("Highlight","Highlight")
-
- dropdown.Items.Add("<span class='BoldGreen'>Bold Green Text</span>", "Bold Green Text", "BoldGreen")
- End If
- End If
2. Edit Dropdown Configuration file (Common.config):
The dropdown configuration file (Common.config) can be found in the /CuteEditor/Configuration/Shared
folder. In dropdown configuration file you can find the CssClass element
which contains the configuration information for the CSS Class dropdown within CuteEditor.
You can modify the CssClass element to create your own CSS Classes list.
Example:
- <dropdowns>
- <CssClass>
- <item text="[[NotSet]]" value="null"></item>
- <item text="Red Text" value="RedColor">
- <html><![CDATA[<span style='color:red'>RedColor</span>]]></html>
- </item>
- <item text="textbold" value="textbold">
- <html><![CDATA[<span class='textbold'>textbold</span>]]></html>
- </item>
- <item text="Highlight" value="Highlight">
- <html><![CDATA[<span style='background-color: yellow'>Highlight</span>]]></html>
- </item>
- <item text="Bold Green Text" value="BoldGreen">
- <html><![CDATA[<span style='color: green; font-weight: bold;'>Bold Green Text</span>]]></html>
- </item>
- </CssClass>
- </dropdowns>
Now the CSS Class dropdown contains "RedColor", "textbold", "Highlight" and "BoldGreen".
Please note that you can use the Editor.EditorWysiwygModeCss Property to specify
the location of the style sheet that will be used by the editable area.
For example:
<CE:Editor id="Editor1" runat="server" EditorWysiwygModeCss="~/example.css"></CE:Editor>
3: Programmatically populate the CSS Class dropdown:
C# Example:
- if (!IsPostBack) {
- CuteEditor.ToolControl toolctrl=Editor1.ToolControls["CssClass"];
- if(toolctrl!=null) {
- CuteEditor.RichDropDownList dropdown=(CuteEditor.RichDropDownList)toolctrl.Control;
-
- CuteEditor.RichListItem richitem=dropdown.Items[0];
-
- dropdown.Items.Clear();
-
- dropdown.Items.Add(richitem);
-
- dropdown.Items.Add("RedColor");
-
- dropdown.Items.Add("Highlight","Highlight");
-
- dropdown.Items.Add("<span class='BoldGreen'>Bold Green Text</span>","Bold Green Text","BoldGreen");
- }
- }
VB Example:
- If Not Page.IsPostBack Then
- If Not Editor1.ToolControls("CssClass") Is Nothing Then
- Dim dropdown As CuteEditor.RichDropDownList
- Dim richitem As CuteEditor.RichListItem
- dropdown = DirectCast(Editor1.ToolControls("CssClass").Control, CuteEditor.RichDropDownList)
-
- richitem = dropdown.Items(0)
-
- dropdown.Items.Clear()
-
- dropdown.Items.Add(richitem)
-
- dropdown.Items.Add("RedColor")
-
- dropdown.Items.Add("Highlight","Highlight")
-
- dropdown.Items.Add("<span class='BoldGreen'>Bold Green Text</span>", "Bold Green Text", "BoldGreen")
- End If
- End If