RadEditor for ASP.NET

GetHtml Send comments on this topic.
See Also
Client-side API Reference > Methods > GetHtml

Glossary Item Box

Returns the editor content as HTML.

function GetHtml (content)

content string The HTML content, that will be set in Telerik RadEditor.

 

Here is a sample example on how to limit the content length in the content area:

ASPX/ASCX Copy Code
<script type="text/javascript">
var limitNum = 100;
var message = 'You are not able to type more than ' + limitNum + ' symbols!';

function OnClientLoad(editor)
{
  var oFun = function()
  {
     var oValue = editor.GetHtml(true); //get the HTML content

     if (oValue.length > limitNum)
     {
       editor.SetHtml(oValue.substring(0, limitNum));
       alert(message);
     }
 };
 editor.AttachEventHandler("onkeyup", oFun);
 editor.AttachEventHandler("onkeydown", oFun);
}
</script>
<
rad:RadEditor id="RadEditor1" OnClientLoad="OnClientLoad" Runat="server"></rad:RadEditor>

 

Remarks:

You should set GetHtml(true); as well as ConvertToXhtml="true".
When setting the true argument, the GetHtml() method will return the html content parsed by the XHTML filter.

 

See Also