Skip to main content

ASPxHtmlEditor.ReplacePlaceholders(String, Dictionary<String, String>) Method

Replaces placeholders with the specified values.

Namespace: DevExpress.Web.ASPxHtmlEditor

Assembly: DevExpress.Web.ASPxHtmlEditor.v24.2.dll

Declaration

public static string ReplacePlaceholders(
    string html,
    Dictionary<string, string> placeholders
)

Parameters

Name Type Description
html String

A string value that specifies the HTML code to process.

placeholders Dictionary<String, String>

The collection of placeholders and values to replace them.

Returns

Type Description
String

A string value that is the resulting HTML code with the placeholders replaced.

Example

This example demonstrates how to replace placeholders with data specified as an object. When the Insert Signature button is clicked, the FirstName and LastName placeholders are replaced using the ASPxHtmlEditor.ReplacePlaceholders method’s ReplacePlaceholders(string html, Dictionary <String, String> placeholders) overload.

<dx:ASPxHtmlEditor ID="HtmlEditor" ClientInstanceName="HtmlEditor" runat="server">
    <Toolbars>
        <dx:HtmlEditorToolbar>
            <Items> ...</Items>
        </dx:HtmlEditorToolbar>
    </Toolbars>
    <Placeholders>
        <dx:HtmlEditorPlaceholderItem Value="DateNow" />
        <dx:HtmlEditorPlaceholderItem Value="TimeNow" />
        <dx:HtmlEditorPlaceholderItem Value="FirstName" />
        <dx:HtmlEditorPlaceholderItem Value="LastName" />
    </Placeholders>
</dx:ASPxHtmlEditor>
<dx:ASPxButton ID="SignatureButton" runat="server" OnClick="Insert_Signature" Text="Insert Signature" />
private Dictionary<string, string> PlaceholdersForSignature = new Dictionary<string, string>() {
    {"FirstName", "Mary"},
    {"LastName", "Bonn"}
};

// Replaces placeholders specified as a dictionary
protected void Insert_Signature(object sender, EventArgs e) {
    string html = HtmlEditor.Html;
    string newHtml = ASPxHtmlEditor.ReplacePlaceholders(html, PlaceholdersForSignature);
    HtmlEditor.Html = newHtml;
}
See Also