RadEditor for ASP.NET

GetSelectionHtml Send comments on this topic.
Client-side API Reference > Methods > GetSelectionHtml

Glossary Item Box

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:

ASPX/ASCX Copy Code
<rad:RadEditor id="RadEditor1" Runat="server"></rad:RadEditor>
<
input type="button" value="Apply Formatting" onclick="SetFormatting()" />
<
script type="text/javascript">
function SetFormatting()
{
   var editor =
<%=RadEditor1.ClientID%>;
   var selection = editor.GetSelectionHtml();
   editor.PasteHtml('
<div style="color: red;font-weight: bold;font-style: italic;">' + selection + '</div>');
}
</script>