ASPxClientHtmlEditorCommandEventArgs.commandName Property
Gets the name of the processed command.
Declaration
commandName: string
Property Value
Type | Description |
---|---|
string | A string value representing the processed command’s name. |
Remarks
Use the commandName property to identify the command currently being processed. Additional information about the command may be obtained by using the ASPxClientHtmlEditorCommandEventArgs.parameter property.
Note that the names of the ASPxHtmlEditor‘s default commands can be obtained on the client side via the ASPxClientCommandConsts object’s constants. In the case of a custom command, this property value depends on the way the custom command is executed.
- If a custom command is executed by a click on a custom toolbar button, commandName matches the CommandName property value.
- If a custom command is executed by a click on a custom ribbon item, commandName matches the RibbonItemBase.Name property value.
- If a custom command is executed with the ASPxClientHtmlEditor.ExecuteCommand function, the commandName matches the corresponding function parameter.
Example
The example below demonstrates how to manipulate ASPxHtmlEditor View Areas by CustomToolbarButton.
- Wrap the ASPxHtmlEditor with the ASPxCallbackPanel to programmatically send a callback to the server.
- Define custom toolbar buttons (CustomToolbarButton) for the ASPxHtmlEditor.
- Handle the client-side ASPxClientHtmlEditor.CustomCommand event and perform a callback by using the ASPxClientCallbackPanel.PerformCallback method.
- Handle the ASPxCallbackPanel.Callback event and define View Areas enabled by the ASPxHtmlEditor.Settings property.
function OnCustomCommand(s, e) {
if(e.commandName == "close") {
cp.PerformCallback("closed");
}
if(e.commandName == "open" || e.commandName == "new")
if(confirm("Are you sure?"))
cp.PerformCallback("opened");
}
<dx:ASPxCallbackPanel ID="cp" runat="server" ClientInstanceName="cp" OnCallback="cp_Callback">
<PanelCollection>
<dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
<dx:ASPxHtmlEditor ID="htmlEditor" runat="server">
<ClientSideEvents CustomCommand="OnCustomCommand" />
<Toolbars>
<dx:HtmlEditorToolbar>
<Items>
<dx:CustomToolbarButton CommandName="new" Text="New" />
<dx:CustomToolbarButton CommandName="open" Text="Open" />
<dx:CustomToolbarButton CommandName="save" Text="Save" />
<dx:CustomToolbarButton CommandName="close" Text="Close" />
</Items>
</dx:HtmlEditorToolbar>
</Toolbars>
</dx:ASPxHtmlEditor>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
protected void Page_Load(object sender, EventArgs e) {
if(!IsPostBack && !IsCallback)
Session["ViewVisible"] = false;
if(Session["ViewVisible"]!=null) {
htmlEditor.Settings.AllowHtmlView = (bool)Session["ViewVisible"];
htmlEditor.Settings.AllowPreview = (bool)Session["ViewVisible"];
}
}
protected void cp_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
if(e.Parameter == "opened") {
htmlEditor.Settings.AllowHtmlView = true;
htmlEditor.Settings.AllowPreview = true;
Session["ViewVisible"] = true;
}
if(e.Parameter == "closed") {
htmlEditor.Settings.AllowHtmlView = false;
htmlEditor.Settings.AllowPreview = false;
Session["ViewVisible"] = false;
}
}
See Also