Back to Devexpress

ASPxRichEdit.InsertContentToClient Event

aspnet-devexpress-dot-web-dot-aspxrichedit-dot-aspxrichedit-a2e238e5.md

latest3.8 KB
Original Source

ASPxRichEdit.InsertContentToClient Event

Fires when the client RichEditCommands.insertContentFromServer command is executed.

Namespace : DevExpress.Web.ASPxRichEdit

Assembly : DevExpress.Web.ASPxRichEdit.v25.2.dll

NuGet Package : DevExpress.Web.Office

Declaration

csharp
public event InsertContentToClientEventHandler InsertContentToClient
vb
Public Event InsertContentToClient As InsertContentToClientEventHandler

Event Data

The InsertContentToClient event's data class is InsertContentToClientEventArgs. The following properties provide information specific to this event:

PropertyDescription
KeepLastParagraphGets or sets whether the last paragraph of the inserted document is kept in the resulting document.
RequestIdGets the identifier of the request to the server.
ResultSpecifies the value passed to the client model.

Remarks

Use the InsertContentToClient event’s handler to create a server-side document’s model and pass it to the client model. The model is passed to the client using the e.Result parameter as demonstrated in the code example below:

aspx
<dx:ASPxButton runat="server" ID="InsertText" Text="Insert Text">
    <ClientSideEvents Click="onInsertTextClick" />
</dx:ASPxButton>
<dx:ASPxButton runat="server" ID="InsertModel" Text="Insert Model">
    <ClientSideEvents Click="onInsertModelClick" />
</dx:ASPxButton>
<dx:ASPxRichEdit ID="ASPxRichEdit1" ClientInstanceName="richEdit" runat="server" 
    WorkDirectory="~\App_Data\WorkDirectory" OnInsertContentToClient="ASPxRichEdit1_InsertContentToClient">
</dx:ASPxRichEdit>
javascript
function onInsertTextClick() {
    richEdit.commands.insertContentFromServer.execute('text', 0, richEdit.document.mainSubDocument.id);
}
function onInsertModelClick() {
    richEdit.commands.insertContentFromServer.execute('model', 0, richEdit.document.mainSubDocument.id);
}
csharp
protected void ASPxRichEdit1_InsertContentToClient(object sender, DevExpress.Web.ASPxRichEdit.InsertContentToClientEventArgs e) {
    if (e.RequestId == "text") {
        e.Result = "Text To Insert";
    }
    if (e.RequestId == "model") {
        var docServer = new RichEditDocumentServer();
        var document = docServer.Document;

        document.AppendText("Model To Insert");
        DocumentRange myRange = document.Paragraphs[0].Range;
        CharacterProperties charProps = document.BeginUpdateCharacters(myRange);
        charProps.FontSize = 30;
        charProps.Bold = true;
        document.EndUpdateCharacters(charProps);
        e.Result = document;
    }
}

Note that the e.Result parameter should be represented by a string or the Document class’s instance.

See Also

ASPxRichEdit Class

ASPxRichEdit Members

DevExpress.Web.ASPxRichEdit Namespace