RadEditor for ASP.NET

Expanding Editor Height Send comments on this topic.
Handling Content > Expanding Editor Height

Glossary Item Box

In the previous version of Telerik RadEditor, the content area was a DIV element. This element supports the overflow property, which provides the ability for the content area to expand its boundaries and always show the content that exceeds its dimensions. The IFRAME element of the new Telerik RadEditor does not support this property but you can use the workaround below.

SOLUTION

The following code will do the automatic resizing in the editor's content area:

ASPX/ASCX Copy Code
<script type="text/javascript">
function resizeContentArea(editor)
{
   if (editor.InitialHeight == -1)
   {
       editor.InitialHeight = editor.Document.body.clientHeight;
   }
   var targetHeight = editor.Document.body.scrollHeight;
   if (targetHeight > editor.InitialHeight)
   {
       var theIFrame = document.getElementById("RadEContentIframe" + editor.Id);
       theIFrame.style.height = parseInt(targetHeight) + "px";
   }
}

function attachResizeEvents(editor)
{
   editor.InitialHeight = -1;
   editor.GetContentArea().style.overflow = "hidden";
   editor.Document.body.scroll = "no";
   var resizeFnRef = function anon(){resizeContentArea(editor)};
   editor.AttachEventHandler("RADEVENT_SEL_CHANGED", resizeFnRef)
   editor.AttachEventHandler("keydown", resizeFnRef)
}
</script>
<
rad:radEditor id="editor1" runat="server" editable="true" onclientload="attachResizeEvents" />
Please note that the script must be placed above the editor declaration. Feel free to modify the provided code.