RichTextEditor
Namespace: Wisej.Web.Ext.Syncfusion2
Assembly: Wisej.Web.Ext.Syncfusion2 (4.1.0.0)
The rich text editor component is WYSIWYG ("what you see is what you get") editor that provides the best user experience to create and update the content. Users can format their content using standard toolbar commands.
- C#
- VB.NET
public class RichTextEditor : ej2Base
Public Class RichTextEditor
Inherits ej2Base
The content of the editor is kept in sync with the Text property: the control handles the change event of the EJ2 component to update Text and fire the TextChanged event. For this reason, a handler attached to Instance.onChange is not registered with the widget: handle TextChanged instead.
Example:
The following example loads HTML content in the editor and receives the content edited by the user.
this.richTextEditor1.Text = "<p>Dear customer,</p><p>thank you for your order.</p>";
this.richTextEditor1.TextChanged += (s, e) =>
{
// the content was changed by the user, or by the code.
this.buttonSave.Enabled = this.richTextEditor1.Text.Length > 0;
};
Constructors
RichTextEditor()
Constructs a new instance of the RichTextEditor class.
Example:
The following example creates a rich text editor, configures it through the Options object, and sets its initial content.
var editor = new RichTextEditor();
editor.Options.placeholder = "Write your message here";
editor.Options.showCharCount = true;
editor.Text = "<p>Hello <b>World</b></p>";
editor.Dock = DockStyle.Fill;
this.Controls.Add(editor);
RichTextEditor(options)
Constructs a new instance of the RichTextEditor class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates a rich text editor with a reduced set of toolbar commands.
var editor = new RichTextEditor(new
{
placeholder = "Notes",
toolbarSettings = new
{
items = new[] { "Bold", "Italic", "Underline", "|", "OrderedList", "UnorderedList", "|", "CreateLink", "|", "Undo", "Redo" }
}
});
editor.Dock = DockStyle.Fill;
this.Controls.Add(editor);
Properties
Text
String: Returns or sets the HTML content of the RichTextEditor. (Default: "")
The value is stored on the server and sent to the editor when it changes; a value assigned before the widget is created in the browser is sent to the editor when it is loaded. Setting the property to null assigns an empty string, and setting a different value fires the TextChanged event.
The property is updated, and the TextChanged event is fired, when the EJ2 component fires its change event after the user has edited the content. The property does not read the value option of the widget.
Example:
// the text can contain HTML tags.
this.richTextEditor1.Text = "<h2>Meeting notes</h2><ul><li>Budget approved</li></ul>";
// read the content edited by the user.
string html = this.richTextEditor1.Text;
Methods
OnWidgetEvent(e)
Processes events from the client-side widget.
| Parameter | Type | Description |
|---|---|---|
| e | WidgetEventArgs |