Current filter:
                                You should refresh the page.
                                  • Hello,

                                    I am currently trying to figure out a way to insert and also edit text within the ASPxRichText web control.

                                    For the insert, I am looking to be able to insert a block of text at the text cursor/caret point . If possible, it would be preferred to do this text insertion asynchronously via javascript or jQuery, but I could also do it on a postback on the server side, though I haven't been able to make headway figuring out either method. From reading over the documentation, it sounds like the DevExpress.Web.ASPxRichEdit.ASPxRichEdit control has a corresponding DocumentServer object, which I would assume would be used to make text based edits/insertions, but I can't seem to find out how to access the DocumentServer tied to the control.

                                    For the text edit, I would be doing this on the server side after loading the text with the Open() method. I believe this could be solved the same way as the text replacing from my previous ticket, if there is a way to access the document within the ASPxRichEdit control.

                                    Any help would be greatly appreciated .

                                    Thank you,
                                    Nick Shaw

                                1 Solution

                                Creation Date Importance Sort by



                                Starting with the 16.1 version, we have implemented a client-side API, which allows you to accomplish this task by using the built-in functionality and avoid using undocumented functions. Use the client-side  ASPxClientRichEdit.commands.insertText property for this purpose:


                                Please see the Client Command API demo for more information about this new client-side functionality.

                                For earlier versions:

                                At present, the ASPxRichEdit control does not have a server-side interface for the underlying document. If necessary, you can load the document to the RichEditDocumentServer component, perform the required manipulations (insert/modify text ranges) and open the modified document in the ASPxRichEdit control (see ASPxRichEdit.Open). As for the client side, there is a non-public API for this purpose:

                                rich.core.commandManager.getCommand(__aspxRichEdit.RichEditClientCommand.InsertText).execute("your text")

                                where "rich" is a value of the ASPxRichEdit.ClientInstanceName property. However, please note that all these commands are internal. So we can change them without warning.


                                • Nickolas Shaw 09.09.2015

                                  Hi Alessandro,
                                  Thank you for your response, this is definitely a step in the right direction of what I'm trying to achieve.
                                  Regarding the loading into the RichEditDocumentServer for insertion/modification, is there a way to pull the cursor/caret location from the ASPxRichEdit control to know where to insert the text range after loading into the RichEditDocumentServer component?
                                  And two questions regarding the client side API, is there a ReplaceText command similar to the InsertText example you provided? And also, is there a version that inserts RTF Text?
                                  Thank you again,

                                • Jenny (DevExpress Support) 09.10.2015

                                   Hello Nick,

                                  You can get the cursor location on the client side using the getLastSelectedInterval method that returns an object containing the start selection index and the selection length. If there are no selected symbols, the length is equal to 0.

                                  rich.core.selection.getLastSelectedInterval() = {start: 0, length: 0}

                                   Where "rich" is the value of the ASPxRichEdit.ClientInstanceName property.

                                  >> And two questions regarding the client side API, is there a ReplaceText command similar to the InsertText example you provided? And also, is there a version that inserts RTF Text?

                                  There are no client-side methods that allow you to replace text or insert a different text keeping the RTF formatting.