Skip to main content

ToolbarCustomCssListEditItem(String, String, String) Constructor

Initializes a new instance of the ToolbarCustomCssListEditItem class with the specified settings.

Namespace: DevExpress.Web.ASPxHtmlEditor

Assembly: DevExpress.Web.ASPxHtmlEditor.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public ToolbarCustomCssListEditItem(
    string text,
    string tagName,
    string cssClass
)

Parameters

Name Type Description
text String

A string value that specifies the item’s text.

tagName String

A string value that specifies the item’s tag name.

cssClass String

A string value that specifies the item’s CSS class name.

Example

This example demonstrates how to programmatically create the standard toolbar item of the ToolbarCustomCssEdit type, and add the CSS file to the web project.

In order to specify a css file that contains definitions of custom css classes, the ASPxHtmlEditor.CssFiles property of the ASPxHtmlEditor can be used. The display text of an editor item can be defined using the item’s ListEditItem.Text property. An item’s ToolbarCustomCssListEditItem.CssClass and ToolbarCustomCssListEditItem.TagName properties are used to associate the item with the corresponding css class name, which defines a specific formatting, and specify the name of a tag to wrap the text content to which the associated style will be applied. The preview style of the item displayed within the drop down list of the ToolbarCustomCssEdit object is defined by using the ToolbarCustomCssListEditItem.PreviewStyle property.

<dx:ASPxHtmlEditor ID="ASPxHtmlEditor1" runat="server">
</dx:ASPxHtmlEditor>
protected void Page_Load(object sender, EventArgs e) {
    HtmlEditorCssFile myCss = new HtmlEditorCssFile();
    myCss.FilePath = "~/Css/Custom.css";
    ASPxHtmlEditor1.CssFiles.Add(myCss);
    CustomToolbar myToolbar = new CustomToolbar();
    ToolbarCustomCssEdit myToolbarButton1 = new ToolbarCustomCssEdit();
    ToolbarCustomCssListEditItem CustomStyle1 = 
        new ToolbarCustomCssListEditItem("Header1", "h1", "CommonHeader1");
    ToolbarCustomCssListEditItem CustomStyle2 = 
        new ToolbarCustomCssListEditItem("Header2", "h2", "CommonHeader2");
    CustomStyle1.PreviewStyle.CssClass = "CommonHeader1";
    CustomStyle2.PreviewStyle.CssClass = "CommonHeader2";
    myToolbarButton1.Items.Add(CustomStyle1);
    myToolbarButton1.Items.Add(CustomStyle2);
    myToolbar.Items.Add(myToolbarButton1);
    ASPxHtmlEditor1.Toolbars.Add(myToolbar);
}
See Also