dxHtmlEditor
Namespace: Wisej.Web.Ext.DevExtreme
Assembly: Wisej.Web.Ext.DevExtreme (4.1.0.0)
HtmlEditor is a WYSIWYG editor that allows you to format textual and visual content and to output it in HTML or Markdown.
- C#
- VB.NET
public class dxHtmlEditor : dxBase
Public Class dxHtmlEditor
Inherits dxBase
Constructors
dxHtmlEditor()
Constructs a new instance of the dxHtmlEditor class. The control is created selectable.
Example:
The following example creates an editor, configures its toolbar and sets the initial content.
var editor = new dxHtmlEditor();
editor.Options.toolbar = new
{
items = new[] { "undo", "redo", "separator", "bold", "italic", "underline" }
};
editor.HtmlText = "<p>Dear <b>customer</b>,</p>";
editor.Dock = DockStyle.Fill;
this.Controls.Add(editor);
dxHtmlEditor(options)
Constructs a new instance of the dxHtmlEditor class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates an editor with a placeholder and a toolbar that includes the heading and list commands.
var editor = new dxHtmlEditor(new
{
placeholder = "Type the description here...",
toolbar = new
{
items = new object[]
{
"bold", "italic", "separator",
new { name = "header", acceptedValues = new object[] { false, 1, 2, 3 } },
"orderedList", "bulletList"
}
}
});
editor.Dock = DockStyle.Fill;
this.Controls.Add(editor);
Properties
HtmlText
String: Returns or sets the content of the dxHtmlEditor as HTML markup.
Setting this property replaces the content of the editor with the specified HTML and fires the TextChanged event. The assigned value is also returned by Text until the user edits the content. A null value is converted to an empty string.
When the user edits the content in the browser, this property returns the edited HTML, Text returns the same content without the HTML tags and the TextChanged event is fired.
Example:
The following example loads an HTML fragment in the editor and saves the markup edited by the user.
this.dxHtmlEditor1.HtmlText = "<h2>Release notes</h2><p>First <b>draft</b>.</p>";
this.dxHtmlEditor1.TextChanged += (s, e) =>
{
string html = this.dxHtmlEditor1.HtmlText;
string plainText = this.dxHtmlEditor1.Text;
SaveDraft(html, plainText);
};
Text
String: Returns or sets the plain text of the dxHtmlEditor. (Default: "")
After the user edits the content in the browser, this property returns the content without the HTML tags. Use HtmlText to read the content with its formatting.
Setting this property on an editor that is already displayed inserts the text at the beginning of the current content; set HtmlText to replace the content. A null value is converted to an empty string and the TextChanged event is fired when the value changes.
Example:
The following example reads the unformatted text typed by the user to validate its length.
if (this.dxHtmlEditor1.Text.Length > 500)
AlertBox.Show("The description cannot exceed 500 characters.");
Methods
OnWidgetEvent(e)
Processes events from the client-side widget.
| Parameter | Type | Description |
|---|---|---|
| e | WidgetEventArgs |