Back to Devexpress

ToolbarComboBox Class

aspnet-devexpress-dot-web-dot-aspxhtmleditor-9e138607.md

latest6.5 KB
Original Source

ToolbarComboBox Class

Implements a combo box custom toolbar item functionality.

Namespace : DevExpress.Web.ASPxHtmlEditor

Assembly : DevExpress.Web.ASPxHtmlEditor.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class ToolbarComboBox :
    ToolbarComboBoxBase
vb
Public Class ToolbarComboBox
    Inherits ToolbarComboBoxBase

Remarks

The ToolbarComboBox class allows you to provide the ASPxHtmlEditor toolbar with custom combo box items.

Properties provided by the ToolbarComboBox class allow you to customize the item appearance and behavior.

Example

This example demonstrates how to create a custom toolbar with different types of custom toolbar items in the ASPxHtmlEditor.

A toolbar item’s CommandName property specifies the name of the command that is executed by this item. The custom command logic is implemented in the ASPxClientHtmlEditor.CustomCommand event handler.

javascript
function OnCommandExecute(s, e) {
     var value = e.parameter;
     switch (e.commandName) {
          case "InsertTemplate":
               InsertTemplate(value);
               break;
          case "InsertSmiley":
               InsertSmiley(value);
               break;
          case "InsertCustomer":
               InsertCustomer(value);
               break;
          case "DeleteAll":
               s.SetHtml(' ');
               break;
     }
}

function InsertTemplate(value) {
     HtmlEditor.GetSelection().SetHtml(value + " ");
}

function InsertSmiley(value) {
     var selection = HtmlEditor.GetSelection();
     var valueInfo = value.split("#");
     selection.SetHtml("");
}

function InsertCustomer(value) {
     HtmlEditor.GetSelection().SetHtml(value);
}
aspx
<dx:ASPxHtmlEditor ID="HtmlEditor" runat="server">
     <ClientSideEvents CustomCommand="OnCommandExecute " />
     <Toolbars>
          <dx:HtmlEditorToolbar Name="myCustomToolbar">
               <Items>
                    <dx:ToolbarDropDownMenu BeginGroupField="BeginGroup" CommandName="InsertTemplate" DataSourceID="MenuDataSource" TextField="Name" ToolTip="Insert Template" TooltipField="ToolTip" ValueField="Text">
                         <Image IconID="support_template_16x16">
                         </Image>
                    </dx:ToolbarDropDownMenu>
                    <dx:ToolbarDropDownItemPicker CommandName="InsertSmiley" DataSourceID="ItemPickerDataSource" ImageUrlField="ImageUrl" ToolTip="Insert Smiley" TooltipField="Tooltip" ValueField="Value">
                    </dx:ToolbarDropDownItemPicker>
                    <dx:ToolbarComboBox CommandName="InsertCustomer" DefaultCaption="Customers" ToolTip="Insert Customer">
                         <PropertiesComboBox DataSourceID="ComboBoxDataSource" TextField="Name" ValueField="Name">
                         </PropertiesComboBox>
                    </dx:ToolbarComboBox>
                    <dx:CustomToolbarButton CommandName="DeleteAll" Text="Delete All">
                    </dx:CustomToolbarButton>
               </Items>
          </dx:HtmlEditorToolbar>
     </Toolbars>
</dx:ASPxHtmlEditor>

<asp:XmlDataSource ID="MenuDataSource" runat="server" DataFile="~/App_Data/MenuData.xml"
     TransformFile="~/App_Data/MenuData.xslt" XPath="//Templates/*" />
<asp:XmlDataSource ID="ItemPickerDataSource" runat="server" DataFile="~/App_Data/ItemPickerData.xml"
     XPath="//Smilies/*" />
<asp:XmlDataSource ID="ComboBoxDataSource" runat="server" DataFile="~/App_Data/ComboBoxData.xml"
     XPath="//Customers/*" />

Implements

IStateManager

IPropertiesOwner

IExpressionsAccessor

Inheritance

Object StateManager CollectionItem ToolbarItemBase HtmlEditorToolbarItem ToolbarDropDownBase ToolbarComboBoxBase ToolbarComboBox

See Also

ToolbarComboBox Members

HTML Editor

DevExpress.Web.ASPxHtmlEditor Namespace