getSelectionHtml | RadEditor for ASP.NET AJAX Documentation
Edit this page

getSelectionHtml

Returns the HTML of the selection.
 
function 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>
Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy