New to Telerik UI for ASP.NET AJAX? Start a 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:
-
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>
-
Add a button to execute the paste command:
ASP.NET<input id="Insert" type="button" value="<--Insert" onclick="PasteTextInEditor(Form1.TextBox1.value);" />
-
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>
-
Test the solution.
EXAMPLE FILES