New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Insert Text from a Text Control at the Cursor Position

The example below demonstrates how to insert text at the cursor position in RadEditor when a button is clicked:

  1. Add a textbox to your page:


    <telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1">
    <asp:TextBox ID="TextBox1" runat="server" Height="97px"></asp:TextBox>
  2. Add a button to execute the paste command:


    <input id="Insert" type="button" value="<--Insert" onclick="PasteTextInEditor(Form1.TextBox1.value);" />
  3. Include the PasteTextInEditor method in your ascx/aspx file. Use the pasteHtml method to paste the content from the textbox:


    <script type="text/javascript">
        function PasteTextInEditor(text)
            var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object    
            editor.pasteHtml(text); //PasteHtml is a method from the editor client side API
  4. Test the solution.


Paste Text To Cursor Position

In this article