SharePoint - Hide the Attachment button from ribbon, edit and display form
Asked By Bookworm on 12-Mar-12 09:16 AM
Hi,
I need tha a user to have edit rights but not to be able to attach a file. How can i do this?
pls it is very urgent to me. If you have any idea pls share.
thnx in advance
[)ia6l0 iii replied to Bookworm on 12-Mar-12 03:06 PM
I guess the Ribbon.TrimById method would hide an element. You should pass the element name to this method. I believe one of the following is the name for the Attachment button. But not sure which one though. So one of the following may work (I have never tried it though)
SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
ribbon.TrimById("Ribbon.ListForm.Edit.Actions.AttachFile");
ribbon.TrimById("Ribbon.ListItem.Actions.AttachFile);
If that does not work, try the answer by "user2388" in the following stack exchange post.
http://sharepoint.stackexchange.com/questions/10062/remove-attach-file-button-from-ribbon
Hope this solves.