Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Editor / ContentAreaMode='Div' property

   
  
 
 
   
Configure RadEditor
Change Edit Mode:
Choose tools file:
Enable / Disable AutoResizeHeight:
Enable/Disable RadEditor:
New Lines as:
Choose Toolbar Mode:
select

  • ContentAreaMode="Div" Property

    This demo demonstrates how to render the RadEditor's content area as an editable DIV element, rather than the default IFRAME content area mode.

    ContentAreaMode - This property specifies if the content area element of RadEditor is editable IFRAME or DIV. There are two values available for the property: "Iframe" and "Div". The default value is "Iframe". These are the main differences between Div and Iframe content area modes:

    • When "Iframe" mode is used the content area has a separate document, which does not automatically inherit the current page style sheets. In this mode the parent page CSS styles are manually copied to the document of the Iframe element. This might decrease the loading performance of the control if multiple styles are defined. In "Div" mode all the styles from the parent page are automatically applied to the content.
    • In "Div" mode the content area is part of the current page, which provides better support for https and document.domain cross server scripting.
    • The "Div" mode offers better compatibility with some screen readers.
    • The "Div" mode supports faster implementation of AutoResizeHeight functionality, which is based on the built-in resize implementation of the DIV element.
    • The "Div" content area mode functionality is based on the contentEditable property of the DIV element.  All major browsers support this property now, including Firefox 3, Safari 3, Opera 10, Google Chrome, and Internet Explorer (since 5.5), however some older browsers do not.
    • One major difference between both modes is that in "Iframe" mode the user can insert FORM tags without breaking the page.
    • Div mode should be used by experienced users only who know and understand the benefits and the potential problems that may occur.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Theme="Default" Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Editor.ContentAreaModeDiv.DefaultCS" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" />
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" />
        <table cellspacing="0" cellpadding="0">
            <tr>
                <td style="vertical-align: top;">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <telerik:RadEditor ContentAreaMode="Div" runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools" Height="515">
                                <ImageManager ViewPaths="~/Editor/Img/UserDir/Marketing,~/Editor/Img/UserDir/PublicRelations"
                                    UploadPaths="~/Editor/Img/UserDir/Marketing,~/Editor/Img/UserDir/PublicRelations"
                                    DeletePaths="~/Editor/Img/UserDir/Marketing,~/Editor/Img/UserDir/PublicRelations">
                                </ImageManager>
                            </telerik:RadEditor>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="CheckBoxListEditMode" />
                            <asp:AsyncPostBackTrigger ControlID="RadioButtonListEditMode" />
                            <asp:AsyncPostBackTrigger ControlID="RadioButtonListAutoResizeHeight" />
                            <asp:AsyncPostBackTrigger ControlID="RadioButtonListEnabled" />
                            <asp:AsyncPostBackTrigger ControlID="ChooseToolbarMode" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
                <td style="padding: 0 0 0 8px; vertical-align: top;" id="decorationZoneElement">
                    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Enabled="true" Title="Configure RadEditor"
                 Expanded="true" style="text-align:left;" HorizontalAlign="Right" Width="200">
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div style="padding: 5px;">
                                    <strong>Change Edit Mode:</strong>
                                    <asp:Label ID="lblEditModes" runat="server" EnableViewState="false"></asp:Label>
    <asp:CheckBoxList RepeatDirection="Vertical" Width="110px" CellPadding="0" CellSpacing="0"
    OnSelectedIndexChanged="CheckBoxListEditMode_SelectedIndexChanged" CssClass="text"
    ID="CheckBoxListEditMode" runat="server" AutoPostBack="True">

                                        <asp:ListItem Value="Design" Selected="True">Design Mode</asp:ListItem>
                                        <asp:ListItem Value="Html" Selected="True">Html Mode</asp:ListItem>
                                        <asp:ListItem Value="Preview" Selected="True">Preview Mode</asp:ListItem>
                                    </asp:CheckBoxList>
                                </div>
                                <div style="padding: 5px;">
                                    <strong>Choose tools file:</strong>
    <asp:RadioButtonList RepeatDirection="Vertical" Width="110px" CellPadding="0" CellSpacing="0"
    OnSelectedIndexChanged="RadioButtonListEditMode_SelectedIndexChanged" CssClass="text"
    ID="RadioButtonListEditMode" runat="server" AutoPostBack="True">

                                        <asp:ListItem Value="FullSet">Full set of tools</asp:ListItem>
                                        <asp:ListItem Value="Default" Selected="True">Default</asp:ListItem>
                                        <asp:ListItem Value="BasicTools">Basic toolset</asp:ListItem>
                                    </asp:RadioButtonList>
                                </div>
                                <div style="padding: 5px;">
                                    <strong>Enable / Disable AutoResizeHeight:</strong>
    <asp:radiobuttonlist repeatdirection="vertical" cellpadding="0" cellspacing="0"
    OnSelectedIndexChanged="RadioButtonListAutoResizeHeight_SelectedIndexChanged"
    cssclass="text" id="RadioButtonListAutoResizeHeight"
    runat="server" autopostback="True">

                                    <asp:listitem value="True">Auto Resize to Fit Content Height (no scrollers)</asp:listitem>
                                    <asp:listitem selected="True" value="False">Fixed-height content Area (with scrollers)</asp:listitem>
                                </asp:radiobuttonlist>
                                </div>
                                <div style="padding: 5px;">
                                    <strong>Enable/Disable RadEditor:</strong>
    <asp:RadioButtonList ID="RadioButtonListEnabled" Width="80px" runat="server" AutoPostBack="true"
    RepeatDirection="Vertical" CssClass="text" CellPadding="0" CellSpacing="0" OnSelectedIndexChanged="RadioButtonListEnabled_SelectedIndexChanged">

                                        <asp:ListItem Value="Enable" Selected="true">Enable</asp:ListItem>
                                        <asp:ListItem Value="Disable">Disable</asp:ListItem>
                                    </asp:RadioButtonList>
                                </div>
                                <div style="padding: 5px;">
                                    <strong>New Lines as:</strong>
    <asp:RadioButtonList ID="NewLineBrButtonList" Width="90px" runat="server" AutoPostBack="true"
    RepeatDirection="Vertical" CssClass="text" CellPadding="0" CellSpacing="0" OnSelectedIndexChanged="NewLineBrButtonList_SelectedIndexChanged">

                                        <asp:ListItem Value="Br" Selected="true">Breaks</asp:ListItem>
                                        <asp:ListItem Value="P">Paragraphs</asp:ListItem>
                                        <asp:ListItem Value="Div">Divs</asp:ListItem>
                                    </asp:RadioButtonList>
                                </div>
                                <div style="padding: 5px">
                                    <div style="padding: 0 4px 0 0; font-weight: bold;">
                                        Choose Toolbar Mode:</div>
                                    <telerik:RadComboBox AutoPostBack="true" ID="ChooseToolbarMode" runat="server" OnSelectedIndexChanged="ChooseToolbarMode_SelectedIndexChanged">
                                        <Items>
                                            <telerik:RadComboBoxItem runat="server" Selected="True" Text="Default" Value="Default" />
                                            <telerik:RadComboBoxItem runat="server" Text="PageTop" Value="PageTop" />
                                            <telerik:RadComboBoxItem runat="server" Text="ShowOnFocus" Value="ShowOnFocus" />
                                            <telerik:RadComboBoxItem runat="server" Text="Floating" Value="Floating" />
                                        </Items>
                                        <CollapseAnimation Duration="200" Type="OutQuint" />
                                    </telerik:RadComboBox>
                                </div>

                            </ContentTemplate>
                        </asp:UpdatePanel>
                </qsf:ConfiguratorPanel>
                </td>
            </tr>
        </table>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451