Context menu for BODY tag not appearing when EditorContentAreaMode is set to Div

4 posts, 1 answers
  1. shadow
    shadow avatar
    58 posts
    Member since:
    Jun 2008

    Posted 22 Nov 2012 Link to this post

    Hello,

    I am adding a context menu to body tag of rad editor control while "EditorContentAreaMode" is set to Div.
    Problem is that, it is not showing the context menu on right click in radeditor content area..

    Below is some code sample:

    Setting Editor properties
    Editor.EditModes = EditModes.Design | EditModes.Html;
     
                Editor.Width = new System.Web.UI.WebControls.Unit("100%", CultureInfo.InvariantCulture);
                Editor.Height = 0;
                Editor.AutoResizeHeight = true;
     
                Editor.ToolbarMode = Telerik.Web.UI.EditorToolbarMode.PageTop;
                Editor.ContentAreaMode = EditorContentAreaMode.Div;
                Editor.BackColor = System.Drawing.Color.Transparent;
                //Editor.StripFormattingOnPaste = Telerik.Web.UI.EditorStripFormattingOptions.MSWordRemoveAll;
                Editor.StripFormattingOptions = EditorStripFormattingOptions.MSWordRemoveAll;
     
                Editor.ToolsFile = "/Modules/HtmlArticle/ToolsFile.xml";
                InternalLinks EditorLinks = new InternalLinks();
                Editor = EditorLinks.LoadLinks(Editor);
                Editor = CSSClass.LoadCSSToParagraphList(Editor);
                Editor.CssClasses.Clear();
                Editor.CssFiles.Clear();
                Editor.CssFiles.Add("/mb/pub/css/default.css");
                Editor.CssClass = "mb_modules_HtmlArticle_articleEditors";

    Adding context menu

       EditorTool SaveDraftTool = new EditorTool();
      SaveDraftTool.Text = "Save Draft";
      SaveDraftTool.Name = "SaveDraft";
      EditorContextMenu forBody = new EditorContextMenu();
      forBody.TagName = "BODY";
      forBody.Tools.Add(SaveDraftTool);
      Editor.ContextMenus.Add(forBody);


  2. shadow
    shadow avatar
    58 posts
    Member since:
    Jun 2008

    Posted 22 Nov 2012 Link to this post

    Well, It seems like body tag is not rendered when 

    ContentAreaMode = Div

    So next question is that how we can add context menu in this case?? I want to get the context menu when user clicks anywhere in content area!!
    EditorContextMenu forBody = new EditorContextMenu();
               forBody.TagName = "DIV";
               forBody.Tools.Add(SaveDraftTool);
               Editor.ContextMenus.Add(forBody);

    It adds the context menu but only appears when user right clicks in empty space in content area!!

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 23 Nov 2012 Link to this post

    Hello,

    The DIV element does not have a body, because it is part of the current page and it is not possible to have two body elements in one page.

    If you want to change the default context menu for the content area assign it to DIV tag. If you want to change it for paragraphs assign it to P tag, e.g.

    <telerik:RadEditor ID="RadEditor1" runat="server" ContentAreaMode="Div">
            <ContextMenus>
                <telerik:EditorContextMenu TagName="DIV">
                    <telerik:EditorTool Name="Bold" />
                </telerik:EditorContextMenu>
                <telerik:EditorContextMenu TagName="P">
                    <telerik:EditorTool Name="Underline" />
                </telerik:EditorContextMenu>
            </ContextMenus>
        </telerik:RadEditor>

    All the best,
    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.
  5. shadow
    shadow avatar
    58 posts
    Member since:
    Jun 2008

    Posted 26 Nov 2012 Link to this post

    Well,

    I got it. And I am assuming that I need to add the context menus for all html tags.

    Thanks for your guidance.
Back to Top