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:

    ASP.NET

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

    ASP.NET

    <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:

    ASP.NET

    <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
        }
    </script>
    
  4. Test the solution.

EXAMPLE FILES

Paste Text To Cursor Position

In this article