This is a migrated thread and some comments may be shown as answers.

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

3 Answers 32 Views
Editor
This is a migrated thread and some comments may be shown as answers.
shadow
Top achievements
Rank 2
shadow asked on 22 Nov 2012, 01:08 PM
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);


3 Answers, 1 is accepted

Sort by
0
shadow
Top achievements
Rank 2
answered on 22 Nov 2012, 02:03 PM
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!!

0
Accepted
Rumen
Telerik team
answered on 23 Nov 2012, 11:22 AM
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.
0
shadow
Top achievements
Rank 2
answered on 26 Nov 2012, 11:42 AM
Well,

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

Thanks for your guidance.
Tags
Editor
Asked by
shadow
Top achievements
Rank 2
Answers by
shadow
Top achievements
Rank 2
Rumen
Telerik team
Share this question
or