SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a scenario where I need to create an application page that is installed to the ECB menu of a specific list only. Is this possible? or is the only way to do it associating the elements file with a list type e.g. task list?

share|improve this question
up vote 1 down vote accepted

Yes it is possible to do that: create ECB items menu only for a list....and even better decide at runtime how many items to put in the ECB menu. For this you need javascript skills.

SharePoint give us some hooks to add custom ECB items using javascript. This hook is the js function: Custom_AddListMenuItems(m, ctx). But the problem is how to add dynamic items in the ECB right ? The solution I've used was to implement a synchronous Ajax call to a custom aspx which returns a xml with items and their actions. Here is the code:

<script language="javascript">

function Custom_AddDocLibMenuItems(m, ctx)

  var request;
  var url = ctx.HttpRoot + 
      "/_layouts/GetCommands.aspx?ListID=" + ctx.listName + 
      "&ItemID=" + currentItemID + 
      "&UserId=" + ctx.CurrentUserId + 
      "&DateTime=" + Date();

   if ( window.XMLHttpRequest )
      request = new XMLHttpRequest();"GET", url, false);
   else if ( window.ActiveXObject )
      request = new ActiveXObject("Microsoft.XMLHTTP");
      if ( request )
      {"GET", url, false);

   if ( request )
      var commands = request.responseXML.getElementsByTagName("Command");
      // for each command found in the returned XML, extract the name, 
      // image Url and script, and a new menu item with these properties
      for ( var i = 0; i < commands.length; i++ )
         var cmdName = commands[i].getElementsByTagName(
         var imageUrl = commands[i].getElementsByTagName(
         var js = commands[i].getElementsByTagName(
         var addSep = commands[i].getElementsByTagName(

         CAMOpt(m, cmdName, js, imageUrl);

         if (addSep == "True")

      // if at least one command was actually added, add a separator
      if ( commands.length > 0 )

   // returning false makes SharePoint render the rest of the standard menu
   return false;   

function Custom_AddListMenuItems(m, ctx)
    Custom_AddDocLibMenuItems(m, ctx);

This script must be placed in a webpart next to the list webpart (in a Content Editor Web Part for ex.)

The idea is not mine, here is the original article. Hope this will help.

share|improve this answer
You're right, using JavaScript it's possible. – Wictor Wilen MCA MCM MVP Oct 14 '09 at 6:19
Please take into account this article on jQuery: the SharePoint band aid. This kind of stuff won't upgrade to SP2010 as the UI is completely different.… – Anonymous Oct 14 '09 at 6:37
How do you know that ? And I'm not agree with that article at all. Using javascript/jquery it is and will be a great way to improve/customize SharePoint controls. Some sp controls simply can't be changed. So "this kind of stuff" was available since SP2003, it is for SP2007 and I'm sure will be too for SP2010. Adding js is not a danger, don't be afraid we are living in a web world. – Ovidiu Becheş-Puia Oct 14 '09 at 12:38

It must be attached to a list template (if you are using the server side features), that has a specific id. I recommend that you create a feature with a hidden list template and list instance and then attaches your ECB to that list template.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.