RichTextBox

in namespace DotVVM.BusinessPack.Controls

Renders a RichTextBox control similar to HTML <textarea> element with rich text editing capabilities.

Usage & Scenarios

RichTextBox edits formatted HTML. Use its default formatting commands or choose the commands available to the author.

Sample 1: Edit an announcement

Bind Html to the document, not its plain text. Edit the announcement to see the HTML as text below the editor. Changed counts changes, and Enabled lets you lock the draft without clearing it.

If you publish user-authored HTML, sanitize it on the server before rendering it as markup.

<dot:CheckBox Checked="{value: Editing}" Text="Allow editing" />
<bp:RichTextBox Html="{value: Announcement}" Enabled="{value: Editing}"
                Changed="{command: Changes = Changes + 1}" />

<p>Changes: {{value: Changes}}</p>
<pre>{{value: Announcement}}</pre>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RichTextBox.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string Announcement { get; set; } = "<p>The library opens at <strong>nine</strong>.</p>";
        public bool Editing { get; set; } = true;
        public int Changes { get; set; }
    }
}

Sample 2: Choose formatting commands

A nonempty Toolbar replaces the default command set. Group related rtb: commands with CommandGroup and use AlignToRight to separate the cleanup action. Select text in the editor to try the commands.

Use ButtonText or ButtonIcon to change a formatting button, and properties such as UriEditorLabel to change a command's popup. Other built-in commands cover paragraph styles, alignment, images, tables, and undo/redo.

<bp:RichTextBox Html="{value: Instructions}">
    <Toolbar>
        <rtb:CommandGroup>
            <rtb:BoldCommand ButtonText="Bold" />
            <rtb:ItalicCommand />
            <rtb:BulletedListCommand />
            <rtb:HyperlinkCommand UriEditorLabel="Reference URL" SaveButtonText="Apply" />
        </rtb:CommandGroup>
        <rtb:CommandGroup AlignToRight="true">
            <rtb:ClearFormattingCommand ButtonText="Clear formatting" />
        </rtb:CommandGroup>
    </Toolbar>
</bp:RichTextBox>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RichTextBox.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string Instructions { get; set; } = "<p>Bring a notebook and a pencil.</p>";
    }
}

Properties

Name Type Description Notes Default Value
property icon Enabled Boolean Gets or sets a value indicating whether the editor's content can be modified.
attribute
inner element
static value
bindable
default
True
property icon Html String Gets or sets the HTML contents of the editor.
attribute
inner element
static value
bindable
default
null
property icon Toolbar List<CommandGroup> Gets or sets a collection of available commands organized in groups.
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon Changed Command Gets or sets the command triggered when the control text (or value) is changed.

HTML produced by the control