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 an action in my document library, but it doesn't work as it supposed.

So I have here definition of my custom action:

      Title="Go to google"
      ControlAssembly="MyProject, Version=, Culture=neutral, PublicKeyToken=xxxxx"
    <UrlAction Url=" />

Basically this action should only be only visible if it is in specified document library, but it doesn't work and it is always shown.

Here is the code:

protected override void OnLoad(EventArgs e)
            if (!Page.IsPostBack)
                _MenuItemTemp.Visible = false;
                    SPDocumentLibrary library = SPContext.Current.List as SPDocumentLibrary;
                    if (library == null)

                    if (library.Title.equals(""))
                        _MenuItemTemp.Visible = true;
    protected override void CreateChildControls()
        _MenuItemTemp = new MenuItemTemplate
            Text = "Go To Google (code)",

I get into the code and everything, but the action menu is just always there and it doesnt matter the visible is false or true ...

And the name comes from the definition and not from code .. if this makes any sens ...

Any help?

share|improve this question

If not already done, would it be possible for you to create a custom content type (even if it's just inheriting from Document), attach the content type to the list and then create the action targeting that content type ? Doing so would avoid any custom development and you can stick with XML definitions (content type, list template / instance, custom actions).

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
   <CustomAction Id="UserInterfaceLightUp.DocLibNewToolbar"
    Title="Go to google">
   <UrlAction Url=""/>
share|improve this answer
no, i really have to be specific on one document library, not basing on content type or whatever, so not an option, has to be with development – Shkipper Apr 4 '13 at 13:23
up vote 0 down vote accepted

After some investigation i understood the issue, it seems that the editcontrolblock is rendered by javascript and basically server side you can't do much. And there is no way doing that.

Hope this helps someone in the future!

share|improve this answer
You could always disable the action if it is not in the correct list, using the EnabledScript property and write some nice javascript function that only returns true if you are actually at the specific list – Robert Lindgren May 3 '13 at 6:19

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.