Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

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'
     }
 }
}
share|improve this answer
    
Where would i do this Mauro? Many thanks –  user2388 Mar 9 '11 at 14:23
add comment

thankyou for your speedy response - much appreciated.

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

(Ok -having problems posting the xml (have had to remove the angle brackets))

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

Best wishes

Bill

share|improve this answer
    
Grr .. the xml in the answer wont keep its format .. sorry ... –  user2388 Mar 9 '11 at 14:32
add comment

Your Answer

 
discard

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