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 / Editor In RadWindow

This demo contains a dialog page for the "Open Advanced Editor" window. To view it, hover over the dropdown button () in the Example Source Code & Description section and press the "EditorInWindow.aspx" item.
   
  
  
   

  • Editor in RadWindow

    This demo shows a common case where the editor is used in a layout with limited space (for example in forums). In such scenario you can define a custom button that will open a RadWindow dialog that contains another editor that has full set of tools, thus allowing your users to get the full functionality of the RadEditor control. Once the user insert and edit the content, it can send it back to the editor on the main page by using RadWindow's and RadEditor's client-side API.

    To add the custom button to the toolbar, put the following inner <telerik:EditorTool Name="RichEditor" ..> tag inside the <Tools> and <telerik:EditorToolGroup tags:

    <telerik:RadEditor ID="RadEditor1">
       
    <Tools>
           
    <telerik:EditorToolGroup>
               
    <telerik:EditorTool Name="RichEditor" Text="Open Advanced Editor" ShowText="true" />
            </
    telerik:EditorToolGroup>
       
    </Tools>
    </telerik:RadEditor>

    Specify an icon for the custom button:

    <style type="text/css">
      .reButton_text  { width: auto !important;  }
      .reToolbar.Telerik .RichEditor {  background-image: url(Icons/Open.gif) !important; }
    <
    /style>

    After that register the code that will launch the dialog and set the content from the parent page to the editor in RadWindow:

    <telerik:RadWindow
                        OnClientShow ="SetDialogContent" 
                        OnClientPageLoad
    ="SetDialogContent"
                        NavigateUrl
    ="EditorInWindow.aspx"
                        ...
                       
     />
    <script type="text/javascript">
    var editorContent = null;

    Telerik.Web.UI.Editor.CommandList["RichEditor"] = function(commandName, editor, args)
    {   
        editorContent
    = editor.get_html(true); //get RadEditor content
       
    $find("<%=DialogWindow.ClientID%>").show(); //open RadWindow
    };

    function
    SetDialogContent(oWnd)
    {            
       
    var contentWindow = oWnd.get_contentFrame().contentWindow;
        if
    (contentWindow && contentWindow.setContent)
        {
           
    window.setTimeout(function()
            {                
                contentWindow.setContent(editorContent)
    ;   //pass and set the content from the mane page to RadEditor in RadWindow
           
    }, 500);
       
    }
    }
    </script>

    The next step is to define the setContent function inside the EditorInWindow.aspx (the page that will be loaded by RadWindow). This function sets the content from RadEditor on the parent page to the editor in RadWindow:

    <script type="text/javascript">    
    function setContent(content)
    {
       
    var editor = $find("<%= editor1.ClientID %>");
        if
    (editor) editor.set_html(content);  //set content from the parent page to RadEditor in RadWindow
    }
    </script>

    To load the editor in RadWindow in FullScreen mode execute this line editor.fire("ToggleScreenMode"); in the OnClientLoad event of RadEditor

    <script type="text/javascript">    
    function OnClientLoad(editor)            
    {
        editor.fire(
    "ToggleScreenMode"); //set RadEditor in Full Scree mode                                
    }
    </script>

    To add a "Save and Close" button on the editor in RadWindow toolbar, put the following tag in the ToolsFile.xml file (this file is available in the demo folder)

    <tool name="SaveAndClose" text="Save and Close" showtext="true"  />

    Add an icon for this button:

    <style type="text/css">
       html
    , form, body {  height: 100%;     margin: 0px; }
       .reButton_text  {  width: auto !important; }
       #editor1Bottom UL {  float:right !important;  }
       .reToolbar.Telerik .SaveAndClose {  background-image: url(Icons/Save.gif) !important; }
    <
    /style>

    To close the window and supply the modified content to the editor on the main page register the OnClientCommandExecuting event and function

    <script type="text/javascript">
    function OnClientCommandExecuting(editor, args)
    {
       
    var commandName = args.get_commandName();   //returns the executed command
       
       
    if (commandName == "SaveAndClose")
       {
           
    var radWindow = GetRadWindow();
           var
    browserWindow = radWindow.get_browserWindow();
           
    browserWindow.SetEditorContent(editor.get_html(true));    //set the editor content on RadWindow to the editor on the parent page
           
    radWindow.close(); //close RadWindow
           
    args.set_cancel(true); //cancel the SaveAndClose command
       

    }
    </script>
    <telerik:RadEditor 
        OnClientCommandExecuting="OnClientCommandExecuting"
        OnClientLoad="OnClientLoad"
       
    ID="editor1" Runat="server" Skin="Telerik"
        ToolsFile="ToolsFile.xml">
    </telerik:RadEditor>

    to obtain and set the content register the SetEditorContent function on the main page:

    <script type="text/javascript">
           
    function SetEditorContent(content)
            {            
               $find(
    "<%=RadEditor1.ClientID%>").set_html(content);  //set content to RadEditor on the mane page from RadWindow
           
    }
    </script>

     

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.EditorInRadWindow.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" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <style type="text/css">
            .reTool .RichEditor
            {
                background: url(Icons/Open.gif) no-repeat center;
            }
            .expandImage
            {
                display: inline-block;
                background-image: url('<%= Page.ResolveUrl("~/Common/styles09/sprite09.gif")%>');
                background-position: -596px -1191px;
                background-repeat: no-repeat;
                width: 15px;
                height: 15px;
            }
        </style>
        </telerik:RadCodeBlock>
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" />
            <qsf:InformationBox ID="InformationBox1" runat="server">
            <span style="font-size: 12px;">This demo contains a dialog page for the "Open Advanced Editor" window. To view it,
                hover over the dropdown button (<span class="expandImage"></span>) in the <em>Example
                    Source Code &amp; Description</em> section</span> and press the "EditorInWindow.aspx" item.
        </qsf:InformationBox>
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadWindow OnClientShow="SetDialogContent" OnClientPageLoad="SetDialogContent"
            NavigateUrl="EditorInWindow.aspx" runat="server" Behaviors="Maximize,Close,Move"
            ID="DialogWindow" VisibleStatusbar="false" Width="800px" Modal="true" Height="700px" />
        <telerik:RadEditor ID="RadEditor1" EnableResize="false" runat="server" Width="460px"
            Height="200px">
            <Tools>
                <telerik:EditorToolGroup>
                    <telerik:EditorTool Name="RichEditor" Text="Open Advanced Editor" />
                    <telerik:EditorTool Name="Bold" />
                    <telerik:EditorTool Name="Italic" />
                    <telerik:EditorTool Name="Underline" />
                    <telerik:EditorTool Name="Cut" />
                    <telerik:EditorTool Name="Copy" />
                    <telerik:EditorTool Name="Paste" />
                    <telerik:EditorTool Name="FontName" />
                    <telerik:EditorTool Name="RealFontSize" />
                </telerik:EditorToolGroup>
            </Tools>
            <Content>
                    <img src="../../Img/productLogoLight.gif" alt="product logo" />is the successor of the well known industry standard Editor for ASP.NET. The tight integration with ASP.NET AJAX and the powerful new capabilities make Telerik's WYSIWYG Editor a flexible and lightweight component, turning it into the fastest loading Web Editor. Among the hottest features are:
                    <ul>
                        <li><em>Single-file, drag-and-drop deployment</em></li>
                        <li><em>Built on top of ASP.NET AJAX</em></li>
                        <li><em>Unmatched loading speed with new semantic rendering </em></li>
                        <li><em>Full keyboard accessibility</em></li>
                        <li><em>Flexible Skinning mechanism</em></li>
                        <li><em>Simplified and intuitive toolbar configuration</em></li>
                        <li><em>Out-of-the-box XHTML-enabled output</em></li>
                    </ul>
            </Content>
        </telerik:RadEditor>

        <script type="text/javascript">
            //<![CDATA[
            var editorContent = null;

            Telerik.Web.UI.Editor.CommandList["RichEditor"] = function(commandName, editor, args)
            {
                editorContent = editor.get_html(true); //get RadEditor content
                $find("<%=DialogWindow.ClientID%>").show(); //open RadWindow
            };


            function SetEditorContent(content)
            {
                //set content to RadEditor on the mane page from RadWindow
                $find("<%=RadEditor1.ClientID%>").set_html(content);
            }


            function SetDialogContent(oWnd)
            {
                var contentWindow = oWnd.get_contentFrame().contentWindow;
                if (contentWindow && contentWindow.setContent)
                {
                    window.setTimeout(function()
                    {
                        //pass and set the content from the mane page to RadEditor in RadWindow
                        contentWindow.setContent(editorContent);
                    }, 500);
                }
            }
            //]]>
        </script>

        <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