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

Integrate RadMenu with Sharepoint problem

2 Answers 113 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Nishim Attreja
Top achievements
Rank 1
Nishim Attreja asked on 07 Jul 2008, 05:12 PM
Hello there,

I am trying to create Contextmenu from RadMenu.Net2 version 4.4.5.0.
I am integrating this contextmenu with radtreeview.net2

ContextMenu code is given below in webpart:
relatedDocContextMenu = new RadMenu();
            relatedDocContextMenu.ID = "relDocContextMenu";
            relatedDocContextMenu.IsContext = true;
            relatedDocContextMenu.RadControlsDir = "/_wpresources/RadMenu.Net2/4.4.5.0_bbe59a8ad3533e68/RadControls";

            SPWeb oWeb = null;
            oWeb = SPContext.Current.Web;
            //Adding RadConTextMenu Items
            RadMenuItem itmFavorite = new RadMenuItem("Add Favorite");
            itmFavorite.ImageUrl = oWeb.Url + "/images/favstar.gif";

            relatedDocContextMenu.Items.Add(itmFavorite);

            RadMenuItem itmEmail = new RadMenuItem("Email");
            itmEmail.ImageUrl = oWeb.Url + "/images/favstar.gif";

            relatedDocContextMenu.Items.Add(itmEmail);

            RadMenuItem itmAlert = new RadMenuItem("Set Alert");
            itmAlert.ImageUrl = oWeb.Url + "/images/favstar.gif";

            relatedDocContextMenu.Items.Add(itmAlert);



            relatedDocContextMenu.ContextMenuElementID = "none";
            relatedDocContextMenu.UseEmbeddedScripts = false;


            apnlRelated.Controls.Add(relatedDocContextMenu);
====
apnlRelated is RadAjaxPanel in whic tree is also there.
=======================

Code to add contextmenu in treeview:
tvRelated = new RadTreeView();
            tvRelated.ID = "tvRelated";
            tvRelated.BeforeClientClick = "BeforeClientClickHandler";
            tvRelated.BeforeClientContextMenu = "ShowRadMenu";
            tvRelated.RadControlsDir = "/_wpresources/RadControls/";
            //tvRelated.ShowLineImages = false;
            //tvRelated.ImagesBaseDir = "/_wpresources/RadControls/Treeview/Skins";
            tvRelated.Skin = "Color";
            tvRelated.NodeBound += new RadTreeView.RadTreeViewEventHandler(tvRelated_NodeBound);
==========
script for ShowRadMenu:
===
private const string relatedDocConTextMenuScriptKey = "RelatedDocConextMenu";
        private string relatedRadContextMenuScript = "<script language='javascript' type='text/javascript'>";

            relatedRadContextMenuScript += "function ShowRadMenu(node, e)";
            relatedRadContextMenuScript += "{    ";
            relatedRadContextMenuScript += " var menu = null; ";
            //relatedRadContextMenuScript += "if (node.Category == 'Folder')";
            //relatedRadContextMenuScript += "{";
            //relatedRadContextMenuScript += "   menu = window['<%= relatedDocContextMenu.ClientID %>'];";window['ctl00_m_g_197245f5_94be_4c1a_8fb1_8a924e6e7f33_relDocContextMenu'];
            //relatedRadContextMenuScript += "}";
            //relatedRadContextMenuScript += "else";
            //relatedRadContextMenuScript += "{";
            relatedRadContextMenuScript += " alert(window['<%= relDocContextMenu.ClientID %>']);  menu = window['<%= relDocContextMenu.ClientID %>']; ";
            //relatedRadContextMenuScript += "}";
            relatedRadContextMenuScript += "  if (menu)";
            relatedRadContextMenuScript += "{";
            relatedRadContextMenuScript += "   menu.Show(e);";
            relatedRadContextMenuScript += "   e.cancelBubble = true;";
            relatedRadContextMenuScript += "   if (e.stopPropagation)";
            relatedRadContextMenuScript += "  {";
            relatedRadContextMenuScript += "e.stopPropagation();";
            relatedRadContextMenuScript += "   }";
            relatedRadContextMenuScript += " e.returnValue = false;";
            relatedRadContextMenuScript += "if (e.preventDefault)";
            relatedRadContextMenuScript += " {";
            relatedRadContextMenuScript += "    e.preventDefault();";
            relatedRadContextMenuScript += "}";
            relatedRadContextMenuScript += "}";
            relatedRadContextMenuScript += "}";
            relatedRadContextMenuScript += "</script>";
================
My problem is when i am right click on treenode this conextmenu should show. Is is calling the ShowRadMenu  funtion but it is not detecting RadMenu object.
alert(window['<%= relDocContextMenu.ClientID %>']);
The Above alert is showing "undefined";

SafeControls Entries:
<SafeControl Assembly="RadMenu.Net2, Version=4.4.5.0, Culture=neutral, PublicKeyToken=bbe59a8ad3533e68" Namespace="Telerik.WebControls" TypeName="*" Safe="True" />

<SafeControl Assembly="RadMenu.Net2, Version=4.4.5.0, Culture=neutral, PublicKeyToken=bbe59a8ad3533e68" Namespace="Telerik.RadMenuUtils" TypeName="*" Safe="True" />

I also tried with var menu = <%= relDocContextMenu.ClientID %>;
but no luck.
I also unchecked in configuration .axd - with "verify that file Exists".

Please help me out in this.

Thanks and Regards,
Nishim Attreja

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Jul 2008, 06:18 AM
Hello Nishim Attreja,

You should use the following code to get the menu client-side object:

relatedRadContextMenuScript += "var menu = window['" + relatedDocContextMenu.ClientID +"']";

['<%= relatedDocContextMenu.ClientID %>'] cannot be used from codebehind because it is a server-side expression evaluated when the ASP.NET runtime parses the ASPX file for the first time.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nishim Attreja
Top achievements
Rank 1
answered on 08 Jul 2008, 10:11 AM
Thanks Albert,

It worked like a charm.. Thanks again.

Thanks and Regards,
Nishim Attreja


Tags
Sharepoint Integration
Asked by
Nishim Attreja
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Nishim Attreja
Top achievements
Rank 1
Share this question
or