Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Getting Started
   [Expand]Concepts
   [Collapse]Examples
     How to: Change the Mail Merge data sources at runtime
     How to: Define the default page settings such as margins, paper kind, landscape etc
     How to: Get a selected text on the client side
     How to: Implement the Format Painter functionality
     How to: Insert RTF text to a document
     How to: Insert text to the end of the document on the client side
     How to: Merge several documents content into a single document
     How to: Open a document using drag-and-drop
     How to: Open SpellChecker dialog via Ribbon
     How to: Save and load documents from a database
     How to: Save words added via the Add to Dictionary option to a custom physical dictionary
     How to: Upload a document in the working directory using drag-and-drop
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Insert RTF text to a document

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T532651.

Currently, ASPxRichEdit doesn't provide a functionality to insert RTF formatted text on the client side so that this format is applied automatically. This example demonstrates a workaround that allows you to insert formatted RTF text to the current document on a button click via an ASPxRichEdit callback.

To implement this scenario, initiate an ASPxRichEdit custom callback via the client-side ASPxClientRichEdit.PerformCallback method and handle the server-side ASPxRichEdit.Callback event. To add the required text in this event handler, you can use the AppendRtfText method of our non-visual RichEditDocumentServer component.
To insert this text at the current caret position in the middle of a document text, obtain this position on the client side by using the RichEditSelection.intervals array object and pass it to the server as a parameter of the ASPxClientRichEdit.PerformCallback method. Then, access this passed value in the server-side Callback event handler and use it to modify the current document position via the Document.CreatePosition method before inserting RTF text.

Is this topic helpful?​​​​​​​