1

Can anyone offer advice please as to how i can remove the 'attach file' menu button form the ribbon only on a specific library?

It is on the default new + edit forms that are loaded ... It needs to be a deployable solution.. ie: I cant just edit in designer ..

I think the way to go is a HideCustomAction .. but i cant seem to get it to work.

This is on Sharepoint 2010 and im using visual studio 2010.

Many thanks all.

Bill

2 Answers 2

1

You should be able to set the SPList.EnableAttachments value to false...

You can also try the code found at : http://www.sharepointdev.net/sharepoint--development-programming/hide-attachments-field-in-displayedit-form-43684.shtml, this looks like inline javascript that you can call from your master page or page layout if you are deploying custom forms for the list.

function HideButton()
{
 var tags = document.getElementsByTagName('a');

 for (var i=0; i < tags.length; i++)
 {
     if(tags[i].title == 'Attach File')
     {
         tags[i].style.display = 'none'
     }

     if(tags[i].id == 'ctl00_m_g_1b517923_1f1a_475a_8e10_57a050a1c53a_ctl00_ctl01_ctl00_toolBarTbl_RptControls_diidIOAttach_LinkText')
     {
        tags[i].style.display = 'none'
     }
 }
}
1
  • Where would i do this Mauro? Many thanks
    – user2388
    Mar 9, 2011 at 14:23
0

I have come up with an answer that works for me which is below, I add this to my elements file voila!

<CustomAction
    Id=RemoveActionButton
    Location=CommandUI.Ribbon>
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition>
          <Location="Ribbon.ListForm.Edit.Actions.AttachFile" />
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>

Your answers where very much valid and appreciated though Mauro

1
  • Grr .. the xml in the answer wont keep its format .. sorry ...
    – user2388
    Mar 9, 2011 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.