Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Problems with custom Context Menu item

  Asked By: Neal    Date: Feb 11    Category: Sharepoint    Views: 7267

I'm trying to create a custom context menu entry for a Document Library.
I've decided to implement this as per this example (Customizing SharePoint
Context Menus: http://blogs.msdn.com/bowerm/articles/175691.aspx). I chose
this method because I need to add this to an existing Document Library and
don't need to alter my Site Definition templates. To summarize, I've
included the script at the end of this post into a hidden Content Editor Web
Part; the custom menu item *does* get added to the Document Library on the
same page.

However, I need to take the example a step further like the example on MSDN
(Customizing the Shortcut Menu for List Items:
sp?frame=true). This example navigates to a custom .aspx page that contains
additional automation to process after the user selects the custom entry on
the context menu.

I've saved the .aspx page as per the requirements in the MSDN article
(Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\60\TEMPLATE\LAYOUTS\1033), but when the javascript located in the
Content Editor Web Part fires via the custom context menu item, the
SubmitFormPost method in the AddToKBArea function completes but cannot
navigate to the address specified - a new page appears with the "File not
found" error.

Am I storing the .aspx page in the correct location? This article
(Determining Where to Build a Custom Application:
p.asp?frame=true) appears to hold a clue, but what the heck does [...] mean
in this example for accessing the page via a URL:


Also, that last article says that "Local_Drive:\Program Files\Common
Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS" is the
location for custom ASPX pages and web applications, which drops the \1033\
regional suffix that the first MSDN article specifies.

I've tried storing my aspx page in the root of inetpub\wwwroot,
inetpub\wwwroot\customwebapps and inetput\testportal\customwebapps (the
latter set to be excluded through the Define Managed Paths page), as well as
60\TEMPLATE\LAYOUTS\1033 and 60\TEMPLATE\LAYOUTS - all return "File Not
Found", "404 Not Found", or "Server Error in '/' Application" (depending on
where I stored them).

Can anybody shed some light on this issue?

<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx)
var strTopicGuid = "2a06c0e-19df-4592-92ca-384865e5b4c6";
var strDisplayText = "Submit to Knowledge Base Topic";
var strImagePath = "";

// parse the URL out of the itemTable
var URL = "";
var index = itemTable.innerHTML.indexOf("href=");
if (index > 0)
var str = itemTable.innerHTML.substr(index + 6);
index = str.indexOf('"');
if (index > 0)
URL = str.substr(0, index);
var strAction = "AddToKBArea('" + ctx.HttpRoot + "', 'FileName=" + URL +
"','TopicGuid=" + strTopicGuid + "')";

// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);

// add a separator to the menu

// false means that the standard menu items should also be rendered
return false;

function AddToKBArea(strHttpRoot, strArgs)
window.onfocus = RefreshOnNextFocus;

//Custom .aspx pages need to be stored here on the server
(PublishToKBAreaCSharp.aspx IS saved here!):
//Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server

//Custom .aspx pages need to be accessed like this:

// need to navigate to this .aspx page, with the file name as a parameter:

// neither of the below methods work - 'File not found'

// Try without 1033 directory
// SubmitFormPost(strHttpRoot + "/_layouts/PublishToKBAreaCSharp.aspx?" +
strArgs + "&Source=" + GetSource());

// Try format as per MSDN article
SubmitFormPost(strHttpRoot + "/_layouts/" + L_Language_Text +
"/PublishToKBAreaCSharp.aspx?" + strArgs + "&Source=" + GetSource());

// Note: not sure if I need to pass GetSource()




No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Problems with custom Context Menu item Or get search suggestion and latest updates.