Remove/Hide the SharePoint Ribbon Menu for specific List/Library

 

You can refer to this topic for “Add Custom Action for specific SharePoint Object (SPWeb, SPList)”: http://trungpv.blogspot.com/2012/02/add-custom-action-for-specific.html

 

Remove the Ribbon Menu for specific List/Library:

string siteURL = http://testsite;
           
using (SPSite site = new SPSite
(siteURL))
            {
               
using (SPWeb
web = site.OpenWeb())
                {

                   
SPList list = web.Lists["Shared Documents"
];
                   
SPUserCustomAction
action = list.UserCustomActions.Add();
                    action.Location =
"CommandUI.Ribbon"
;

                    action.Sequence = 0;
                    action.CommandUIExtension =
@"<CommandUIExtension>
                                      <CommandUIDefinitions>
                                                <CommandUIDefinition
                                                 Location=""Ribbon.ListForm.Display.Manage"" />
                                                 <CommandUIDefinition
                                                 Location=""Ribbon.ListForm.Display.Manage.CheckOut"" />
                                         <CommandUIDefinition
                                                 Location=""Ribbon.ListForm.Display.Manage.CheckIn"" />
                                      </CommandUIDefinitions>
                             </CommandUIExtension>"
;
                    action.Update();
                }
            }
The list of Server Ribbon Ids: http://msdn.microsoft.com/en-us/library/ee537543.aspx
 

Comments

Popular posts from this blog

Setup SharePoint 2010

Register CSS to SP Master Page