(function() {
var currentMenu = null;
function onHtmlEditorInit(s, e) {
s.SelectionChanged.AddHandler(function() {
var selectedElement = s.GetSelection().GetSelectedElement();
currentMenu = ASPxClientUtils.GetParentByTagName(selectedElement, "OL");
});
s.CustomDialogClosing.AddHandler(function(sender, args) {
if(args.status == "ok")
setMenuProperties(currentMenu, s);
});
s.CustomCommand.AddHandler(function(sender, args) {
if(args.commandName == "tryShowListProperties") {
if(!currentMenu)
s.ExecuteCommand(ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND);
setTimeout(function() {
if(currentMenu)
s.ExecuteCommand(ASPxClientCommandConsts.CUSTOMDIALOG_COMMAND, "ListProperties");
else
alert("selection does not contain an ordered list");
}, 100);
}
});
}
function onDialogFormInitialized(s, e) {
listProperty_compact.SetChecked(parseInt(currentMenu.style.lineHeight) < 100);
listProperty_start.SetValue(currentMenu.start || 1);
listProperty_type.SetValue(currentMenu.type || "1");
listProperty_compact.CheckedChanged.AddHandler(updatePreview);
listProperty_start.ValueChanged.AddHandler(updatePreview);
listProperty_type.ValueChanged.AddHandler(updatePreview);
updatePreview();
}
function updatePreview() {
var menuSample = document.createElement("OL");
setMenuProperties(menuSample);
menuSample.innerHTML = "<li>Item 1</li><li>Item 2</li><li>Item 3</li><li>Item 4</li>";
listProperty_preview.SetContentHtml(menuSample.outerHTML);
}
function setMenuProperties(menu, htmlEditor) {
menu.style.lineHeight = listProperty_compact.GetChecked() ? "80%" : "";
menu.start = listProperty_start.GetValue();
menu.type = listProperty_type.GetValue();
if(htmlEditor)
htmlEditor.SaveToUndoHistory();
}
window.onDialogFormInitialized = onDialogFormInitialized;
window.onHtmlEditorInit = onHtmlEditorInit;
})()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class S35859 : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
HtmlEditor1.Html = System.IO.File.ReadAllText(MapPath("~/TestHtml.html"));
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="S35859" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="CustomScript.js"></script>
</head>
<body>
<form id="form1" runat="server">
<dx:ASPxHtmlEditor runat="server" ID="HtmlEditor1">
<ClientSideEvents Init="onHtmlEditorInit" />
<CustomDialogs>
<dx:HtmlEditorCustomDialog Caption="ListProperties" Name="ListProperties" FormPath="CustomDialogForm.ascx" />
</CustomDialogs>
<Toolbars>
<dx:HtmlEditorToolbar>
<Items>
<dx:ToolbarUndoButton></dx:ToolbarUndoButton>
<dx:ToolbarRedoButton></dx:ToolbarRedoButton>
<dx:CustomToolbarButton BeginGroup="true" CommandName="tryShowListProperties">
<Image IconID="format_listbullets_16x16" AlternateText="List Properties"></Image>
</dx:CustomToolbarButton>
</Items>
</dx:HtmlEditorToolbar>
</Toolbars>
</dx:ASPxHtmlEditor>
</form>
</body>
</html>
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Partial Public Class S35859
Inherits System.Web.UI.Page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
HtmlEditor1.Html = System.IO.File.ReadAllText(MapPath("~/TestHtml.html"))
End If
End Sub
End Class
(function() {
var currentMenu = null;
function onHtmlEditorInit(s, e) {
s.SelectionChanged.AddHandler(function() {
var selectedElement = s.GetSelection().GetSelectedElement();
currentMenu = ASPxClientUtils.GetParentByTagName(selectedElement, "OL");
});
s.CustomDialogClosing.AddHandler(function(sender, args) {
if(args.status == "ok")
setMenuProperties(currentMenu, s);
});
s.CustomCommand.AddHandler(function(sender, args) {
if(args.commandName == "tryShowListProperties") {
if(!currentMenu)
s.ExecuteCommand(ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND);
setTimeout(function() {
if(currentMenu)
s.ExecuteCommand(ASPxClientCommandConsts.CUSTOMDIALOG_COMMAND, "ListProperties");
else
alert("selection does not contain an ordered list");
}, 100);
}
});
}
function onDialogFormInitialized(s, e) {
listProperty_compact.SetChecked(parseInt(currentMenu.style.lineHeight) < 100);
listProperty_start.SetValue(currentMenu.start || 1);
listProperty_type.SetValue(currentMenu.type || "1");
listProperty_compact.CheckedChanged.AddHandler(updatePreview);
listProperty_start.ValueChanged.AddHandler(updatePreview);
listProperty_type.ValueChanged.AddHandler(updatePreview);
updatePreview();
}
function updatePreview() {
var menuSample = document.createElement("OL");
setMenuProperties(menuSample);
menuSample.innerHTML = "<li>Item 1</li><li>Item 2</li><li>Item 3</li><li>Item 4</li>";
listProperty_preview.SetContentHtml(menuSample.outerHTML);
}
function setMenuProperties(menu, htmlEditor) {
menu.style.lineHeight = listProperty_compact.GetChecked() ? "80%" : "";
menu.start = listProperty_start.GetValue();
menu.type = listProperty_type.GetValue();
if(htmlEditor)
htmlEditor.SaveToUndoHistory();
}
window.onDialogFormInitialized = onDialogFormInitialized;
window.onHtmlEditorInit = onHtmlEditorInit;
})()
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="S35859" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="CustomScript.js"></script>
</head>
<body>
<form id="form1" runat="server">
<dx:ASPxHtmlEditor runat="server" ID="HtmlEditor1">
<ClientSideEvents Init="onHtmlEditorInit" />
<CustomDialogs>
<dx:HtmlEditorCustomDialog Caption="ListProperties" Name="ListProperties" FormPath="CustomDialogForm.ascx" />
</CustomDialogs>
<Toolbars>
<dx:HtmlEditorToolbar>
<Items>
<dx:ToolbarUndoButton></dx:ToolbarUndoButton>
<dx:ToolbarRedoButton></dx:ToolbarRedoButton>
<dx:CustomToolbarButton BeginGroup="true" CommandName="tryShowListProperties">
<Image IconID="format_listbullets_16x16" AlternateText="List Properties"></Image>
</dx:CustomToolbarButton>
</Items>
</dx:HtmlEditorToolbar>
</Toolbars>
</dx:ASPxHtmlEditor>
</form>
</body>
</html>