Dipper Park

Technical Blogs focus on SharePoint Server, SQL Server, Business Intelligence, Master Data Management and others

How to Remove or hiding items in List toolbar in Sharepoint Server 2007

How to Remove or hiding items in List toolbar in Sharepoint Server 2007

Rate This
  • Comments 52

Last week one ISV asked me that he wanted to hide/remove the "New" or "Actions" menu of the Document Library Toolbar in Sharepoint 2007, maybe this would be great needs for you, now I post the way to realize this:

To realize this, you need to override the .ascx based toolbar templates by using a custom template that overrides a toolbar, and thereby customize a toolbar. Please save the following code into nonewbuttonfordoclibtemplates.ascx, and then drop it into C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES and IISRESET, you should be missing the New button on your document library toolbars.

 

<%@ Control Language="C#"   AutoEventWireup="false" %>

<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>

<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

 

<SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">

        <Template>

asdfasfasdfasdf

                <wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl" ButtonSeparator="<img src='/_layouts/images/blank.gif' alt=''>" RightButtonSeparator="&nbsp;&nbsp;" runat="server">

                        <Template_Buttons>

                                <SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/>

                                <SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>

                        </Template_Buttons>

                        <Template_RightButtons>

                                  <SharePoint:PagingButton runat="server"/>

                                  <SharePoint:ListViewSelector runat="server"/>

                        </Template_RightButtons>

                </wssuc:ToolBar>

        </Template>

</SharePoint:RenderingTemplate>

 

Leave a Comment
  • Please add 1 and 3 and type the answer here:
  • Post
  • Hi,

    Great post and very insightful.  It's amazing how your single post has turned out to be more helpful than any article I have read on MSDN about customizing styles.  Maybe I have been looking in the wrong place (but I have been looking for hours).  

    My first questions is:  

    I am trying to customize the style for the toolbar but only for a specific site.  Where is the style called "ms-menutoolbar" and how can I edit the style so it only affects the toolbar in my top level site collection AND the subsites?

    I do NOT want the style change to affect other site collections.

    My next question is more related to your post but also related to my last question:

    How can I change the toolbar to only apply to the site collection and all subsites but not to all site collections?

    Thanks!

  • Thank you very very much this was helpfull

  • Hi!

    There is simplest way to hide these items. Open your page in SP Designer. Right click on web part and select "Convert to XSLT Data View". Next, you can click on toolbar's items and remove them by pressing DEL.

    BUT! It will be not WebPart any more!

    Regards,

    Cinek

  • How can I add new buttons on the toolbar?

  • can i change the name of items in the toolbar(eg. instead of "Actions"---->"you can" or instead of "new"--->"my text" )

  • Thanks, Really Helpful

    Do u have idea how we can add new button on the toolbar? if yes, where will the button action go?

  • Thanx for this tip! Unfortunately this works for the complete site. Do you know if it's possible to combine this with a feature, so I can deal this with only the documentlibraries in one single subsite?

    With kind regards,

    René van der Enden

  • Here is code for a Picture Library. I needed to remove the Actions Menu but keep the Settings and Upload.

    <%@ Control Language="C#"   AutoEventWireup="false" %>

    <%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

    <%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

    <%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>

    <%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

    <%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

    <SharePoint:RenderingTemplate ID="PictureLibraryViewToolBar" runat="server">

           <Template>

                   <wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl" ButtonSeparator="<img src='/_layouts/images/blank.gif' alt=''>" RightButtonSeparator="&nbsp;&nbsp;" runat="server">

                           <Template_Buttons>

                                              <SharePoint:UploadMenu AccessKey="<%$Resources:wss,tb_UploadMenu_AK%>" runat="server"/>

          <SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>

                           </Template_Buttons>

                           <Template_RightButtons>

                                     <SharePoint:PagingButton runat="server"/>

                                     <SharePoint:ListViewSelector runat="server"/>

                           </Template_RightButtons>

                   </wssuc:ToolBar>

           </Template>

    </SharePoint:RenderingTemplate>

  • I need to hide the Manage Permission and Manage Copies button form the toolbar of DispForm.aspx in picture library. This should be application only to a particular subsite. Other picture library should not be affected.

    Plz. suggest a way to do so.

  • Has anyone figured out how to do this only to particular sites or subsites?  Doing this across the board on the server isn't really an option.  Thanks!

  • Hi, i have read this article and want to ask some questions.

    As mentioned in previous comments, button of the toolbar can be hide, but after hide the button, it would not be the webpart.

    I want to know that how can i hide an items of the "Action" Menu.

    For example, i want to hide the "Open with Windows Explorer" of the "Action" Menu.

    How can i do it. I had tried to find the toolbar.ascx template from the path "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES", but it seems to be useless.

    I also tried to use SP Designer to view the  webpart as XSLT format, i only found this "<SharePoint:ActionsMenu runat="server"/>"

    but how can i access and modify the menuitem from the code.

  • Here's how to do this only for certain sites: Add code to the new ascx that checks the SPContext object, and adds the appropriate version of wsuuc:ToolBar depending on which site you're on, which template it uses (.WebTemplate + .Configuration), or just about anything else you like.  Then you can have the standard toolbar for ordinary sites, and the custom one for only a few.  

    As for hiding elements, you can create your own class that inherits from ActionsMenu, NewMenu, etc., and remove the items you don't want.  Then refer to that class in the Template_Buttons section.  In the class, just override AddMenuItems, call base.AddMenuItems() and afterwards loop through MenuTemplateControls.Controls, and remove or change as you like.  Alternatively you can delete the call to base.AddMenuItems, and use AddMenuItem to add the items that you do want.  You can also inherit directly from ToolBarMenuButton, (not much difference).  

  • Thanks for Bjørn Stærk.

    Useful inforamtion.

    But i would like to ask some stupid question.

    How can i inherits that ActionsMenu?

    As i guess, Sharepoint class(.cs/.vb) is generated as .dll format, so we only can inherits it?

    As you said, "Then refer to that class in the Template_Buttons section."

    What is the meaning of "Template_Buttons section". A file name? or... It is because I can't find this file by the search function.

    Thanks!

  • I have been trying to figure out this:

    Why does Read-only-members have access to the option "Open with Windows Explorer" ? Throught the Explorer these members can edit and delete files!

    So I don't want to hide it, cause it should be available for the site members with full control rights. :\

  • Is is because this is the requirement of my cilent.

    He would like to create a group of accouns that has the permission to Read Write Execute of the files.

    The main purpose of hiding the "Open with Windows Explorer" is to ensure users to input some attribute for each file, or to force to run the workflows or events during upload the files by the SharePoint web-based interface.

    To ensure the information consistency, i must hide "Open with Windows Explorer".

Page 1 of 4 (52 items) 1234