RadEditor for ASP.NET

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

Glossary Item Box

Returns a reference to the current RadEditorSelection object.

The RadEditorSelection object is used to provide information on the text/objects selected currently in the Telerik RadEditor Content Area.

 

Example:

This example demonstrates how to pop up an alert message with the currently selected text and html:

ASPX/ASCX Copy Code
<rad:radeditor
  
id="RadEditor1"
  
runat="server">
  
This RadEditor instance contains some <span style="color:white;background-color:red;">formatted</span> content
</rad:radeditor>
<
script type="text/javascript">
function showSelectedContent()
{
  //Get a reference to the client-side RadEditor object:
  var myRadEditor = GetRadEditor("
<%= RadEditor1.ClientID %>");
  var theSelectionObject = myRadEditor.GetSelection();
  var theSelectedText = theSelectionObject.GetText();
  var theSelectedHtml = theSelectionObject.GetHtmlText();
  alert("The selected text is:\n" + theSelectedText + "\n\nin contrast to the selected Html:\n" + theSelectedHtml);
}
</script>
<input type="button" onclick="showSelectedContent();" value="Show"/>