Online Training On SharePoint

Tuesday, 20 September 2011

Hiding Site Action Button for Contributors in SharePoint 2010

We have a requirment where we need to hide the Site Action button in a SharePoint site as we want them to discourage going into any internal pages (though they can always do that using the URL's :)).

This would be complicate to achieve if we try to hide it using some JavaScript or use someother code. A very  simple way to do this if we use a special control given in SharePoint for hiding the controls based on the permissions what the users has. We can use SPSecurityTrimmedControl for this purpose. This control displays the contents of the control to the current user only if the current user has permissions defined in the Permissions attribute. Whatever is the inner content of the control will therefore not be shown if the user doesn't have the specified permissions. This control executes on the server side.

Now to use this control simply we need to open the V4.master page in SharePoint designer and locate the control which renders the Site Action button. You can find this control by searching "SharePoint:SiteActions". Now we need to put SPSecurityTrimmedControl on top of this control:

<sharepoint:spsecuritytrimmedcontrol permissions="ManageWeb" runat="server">

Code for Site Action Button


We have used the Permissions value as ManageWeb so that contributors will also not see this control. Other permissions can also be used.

Post a Comment
Related Posts with Thumbnails