Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Custom context-sensitive menu items in v3 ?

  Asked By: Parvesh    Date: Nov 01    Category: Sharepoint    Views: 3032

I have been struggling with this for a while ..

First, there is Custom_AddListMenuItems and Custom_AddDocLibMenuItems
in wss2003, which used to go into custom_ows.js files.
In that function, you could pull up javascript context on currently
populating menu item, figure out thedocument name, extension, its
checkout status and do other nice stuff, based on the status of the
actual document or list item.

Now, these javascript calls are still present in 2007 scripts, but i
have a hard time figuring out where should i put my javascript so that
it would be available globally, and would fit into Features concept.

The logical way to do this, according to SDK would be to take the
CustomAction, set its location to EditControlBlock and bind it to a
ControlClass, as done here for example for StandardMenu:
This, unfortunately, does not play. It seems that ECB ( and a few
other customaction locations ) do not want to call specified
ControlClasses at all. If anyone knows if they should, or could be
forced to, please let me know. Simply inheriting a public control from
WebControl and pointin an ECB customAction to it does not even load
the assembly. It does load it for the other customAction locations.

Ok, so i started thinking on how to squeeze javascript(or HTML) into
Feature at all, so that it would be visible on all pages. Turns out,
we have Delegate Controls for that, and some of them seem to be
present on all pages. Quick grep through sources turned up:
ControlId="GlobalSiteLink1",ControlId="SmallSearchInputBox" etc.

So how exactly does one implement a delegate control for
AdditionalPageHead, which would render a bit of Javascript that would
customize popup menus globally using Custom_AddDocLibMenuItems ?
Or even better, is there still a way to do the same thing on server
side, getting the ECB customAction to work and create MenuItemTemplate
based on SPContext.Current.ListItem data or something like that ?



1 Answer Found

Answer #1    Answered By: Constance Guerrero     Answered On: Nov 01

Replying to my own post, just implement an control derived from
WebControl, create a new ScriptLink class, give it a name  of the
script in 1033 ( like, customscript.js for example ) and add to

Register that control as a delegate to AdditionalPageHead in the
feature, and deploy customscript.js as a TemplateFile element of a

This script will be then included in all pages where the feature is
deployed, or so i think.

Will post the code if anyone wants.

Still, why does the ECB not call its bound CustomAction controls ?

Didn't find what you were looking for? Find more on Custom context-sensitive menu items in v3 ? Or get search suggestion and latest updates.