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

getSelectionHtml

Returns the HTML of the selection.

getSelectionHtml()

The example below demonstrates how to get the selected HTML and wrap it inside a DIV element with applied formatting:

<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1">
    <Content>        
        Here is sample content!    
    </Content>
</telerik:RadEditor>
<input type="button" value="Apply Formatting" onclick="SetFormatting()" />
<script type="text/javascript">
    function SetFormatting()
    {    
        var editor = $find("<%=RadEditor1.ClientID%>");//get a reference to RadEditor client object    
        var selection = editor.getSelectionHtml();
        editor.pasteHtml('<div style="color: red;font-weight: bold;font-style: italic;">' + selection + '</div>');
    }
</script>
In this article