Accessing Content Element of Editor

4 posts, 0 answers
  1. Rashim
    Rashim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 19 Sep 2011 Link to this post

    Hi ,
    I want to access a div inside the content of the editor. What i have done is given below.

    <telerik:RadEditor runat="server" ID="RadEditor1">
            <Tools>
                <telerik:EditorToolGroup>
                    <telerik:EditorTool Name="DragAndDropContainer" Text="Drag and Drop a div"  />                 
                </telerik:EditorToolGroup>
            </Tools>
            <Content>
                <div id="dragable1" style="position: relative; width: 50px; height: 50px; background: none repeat scroll 0% 0% silver;
                border: 1px dashed red; left: 294px; top: 3px;" >
            </div>
            </Content>
        </telerik:RadEditor>

    <script type="text/javascript">
            //<![CDATA[
            Telerik.Web.UI.Editor.CommandList["DragAndDropContainer"] = function(commandName, editor, args)
            {
                if (editor.getSelectionHtml() != "")
                {
                    editor.fire("FontSize", {value : "4"}); //fire the FontSize command
                    editor.fire("ForeColor", {value : "red"}); //fire the ForeColor command
                }
                else
                {         
                DragHandler.attach(document.getElementById('dragable1'));            
                }
            };

    In this case document.getElementById('dragable1') returns null. Could anyone help how should i access this div.

    Thanks,
    Rashim
  2. Rumen
    Admin
    Rumen avatar
    14028 posts

    Posted 21 Sep 2011 Link to this post

    Hello Rashim,

    Try setting the ContentAreaMode property of RadEditor to DIV, so that the content area becomes part of the current page.
    In the other case the content area will be iframe which is another document and DragHandler function will be not accessible in it. You can access elements in the iframe content area using editor.get_document().body client method.


    Best wishes,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Rashim
    Rashim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 22 Sep 2011 Link to this post

    Yeah that's fine. But if i set the ContentAreaMode property of RadEditor to DIV the div element inside the content area I could not re-size it.
    Could you please help me in this regard

    Thanks,
    Rashim
  4. Rumen
    Admin
    Rumen avatar
    14028 posts

    Posted 23 Sep 2011 Link to this post

    Hi Rashim,

    When the content area is rendered as an editable div, then the absolutely positioned div element in it can be resized only in IE. This feature is offered in IE only when the ContentAreaMode property is set to DIV.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top