次の方法で共有


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

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>

Comments

  • Anonymous
    December 21, 2006
    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!

  • Anonymous
    April 02, 2007
    Thank you very very much this was helpfull

  • Anonymous
    April 05, 2007
    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

  • Anonymous
    June 11, 2007
    How can I add new buttons on the toolbar?

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

  • Anonymous
    July 09, 2007
    Thanks, Really Helpful Do u have idea how we can add new button on the toolbar? if yes, where will the button action go?

  • Anonymous
    July 26, 2007
    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

  • Anonymous
    August 09, 2007
    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>

  • Anonymous
    September 10, 2007
    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.

  • Anonymous
    September 12, 2007
    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!

  • Anonymous
    September 19, 2007
    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 FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATECONTROLTEMPLATES", 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.

  • Anonymous
    September 25, 2007
    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).  

  • Anonymous
    September 26, 2007
    The comment has been removed

  • Anonymous
    September 28, 2007
    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. :

  • Anonymous
    October 01, 2007
    The comment has been removed

  • Anonymous
    October 07, 2007
    I am not sure what you meant, but what I want is this: Read members should NOT see the "Open in windows explorer" option How do you hide it? Thanks again

  • Anonymous
    October 16, 2007
    The comment has been removed

  • Anonymous
    November 05, 2007
    I've tried this code and can't get it to work there is no chnage to my document libarary what am I not doing thanks Dave

  • Anonymous
    November 06, 2007
    I've tried the sample code abopve and cannot get it to work. I would like to remove the multiple upload options from the Document Library toolbar.  Is there any way to do this.

  • Anonymous
    November 14, 2007
    Very nice post. It helped me a lot. But i need one more thing. Do you know any way to hide dictionary from the toolbar of edit forms?

  • Anonymous
    November 21, 2007
    Hi 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. Thx's

  • Anonymous
    December 10, 2007
    Hi, How to hide the same with given sub site.

  • Anonymous
    January 02, 2008
    Hi, I want to remove "Actions" and "Uploads" only if user is "Contributor" role. Can this solution do? Thank you very much.

  • Anonymous
    January 27, 2008
    Hi, Very Nice article. By reading this document I can Hide New button on "Document Library" and "Picture Library". Can you please let me know, How do I hide New button on the document library created based on "Custom document library template" ? And another thing, How do I deploy this ascx control using Feature? Thanks in Advance.

  • Anonymous
    February 13, 2008
    I have a similar question as Rupali...how can I do this with other list types?  i.e. Announcements or Custom List.

  • Anonymous
    February 13, 2008
    Hi I want to do this in a listview webpart which is a child control of my WP, is this possible?

  • Anonymous
    February 14, 2008
    Hi, i want to know how can i hide/remove the multiple upload button from the upload menu.

  • Anonymous
    February 22, 2008
    same problem here, need to remove/hide the single upload button from the upload menu. no luck on any trials. anyone can help?

  • Anonymous
    February 22, 2008
    ah, got a solution, not necessarily a good one, but works for my need. http://asadewa.wordpress.com/2008/02/23/removing-single-file-upload-menu-from-document-library-toolbar-moss-2007/

  • Anonymous
    April 15, 2008
    Would anyone be willing to post the code to hide the Export to excel option so that I can remove it for the survey function of the site. I am not a programmer so simple instructions such as the ones listed above would do wonders for me. Thank you so much!!! Shanea

  • Anonymous
    April 15, 2008
    Hiding toolbar menu items in a Sharepoint list

  • Anonymous
    June 16, 2008
    Something similar. Removing the Attachment button from the Form Tool bar on NewForm.aspx and EditForm.aspx http://ketulpatel.wordpress.com/2008/06/16/removing-attachment-button-from-moss-form-toolbar/

  • Anonymous
    June 17, 2008
    Новая инфа: Как убрать элементы в стандартном toolbar'е в формах изменения, создания, просмотра элемента...

  • Anonymous
    September 07, 2008
    If you would like to have some paragraphs translated from Polish to English please leave a comment. Post

  • Anonymous
    September 16, 2008
    But, how are you pointing the lists to now use nonewbuttonfordoclibtemplates.ascx rather than what it wants to use?

  • Anonymous
    November 10, 2008
    I test this code,but it's not work...

  • Anonymous
    November 26, 2008
    How to hide New Menu of Custom List

  • Anonymous
    December 15, 2008
    i need to remove upload and settings menu in form library tool bar.

  • Anonymous
    January 12, 2009
    This really is a great post and it's about the closest I've come to resolving my issue. I need to simply hide the edit button on the menu bar. This is for the calendar and the menu that I'd like to customize is the displayed in the dispForm. This view shows the edit function but again this is where I have a need to remove the 'edit button'. In doing so I'm hoping to remove users ability to edit items as this should only be an admin function. tmacon@cio.sc.gov

  • Anonymous
    January 24, 2009
    I have done that using javascript .. check this article .. http://www.codeproject.com/KB/sharepoint/sharepoint-customization.aspx

  • Anonymous
    February 02, 2009
    Has anyone figured out how to do this only to particular sites/subsites/Document Libraries only?  Doing this across the board on the server isn't really an option as all the Document Libraries on that particular Site/Subsite takes into effect.Thanks!

  • Anonymous
    February 10, 2009
    Hi can we do this from Schema.xml

  • Anonymous
    April 06, 2009
    SharePoint Customizing SharePoint Context Menus Hidden SharePoint Lists, Fields, and other Advanced List

  • Anonymous
    April 09, 2009
    it's nice article which saves my time. I want hide "view" i mean creat view and modify view options in the list menu bar.How do you do that

  • Anonymous
    April 16, 2009
    Hi, Can anyone give me a javascript which I can use in a content editor webpart to Hide "Edit in Microsoft Office InfoPath" and "Edit Properties" menu items? Please dont refer me to some other blog. Thanks :) I already have one function like below: function CAMOpt(p,wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc) { var mo=CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc); if(!mo) return null; if(wzText != "Edit in Microsoft Office InfoPath" && wzText != "View Properties") if(wzText != "Edit Properties") AChld(p,mo); return true; } BUT this is working only when I am in ".....?PageView=Shared" view of the page. NOT in AllItems.aspx page.

  • Anonymous
    June 09, 2009
    Take a look at this http://www.shillier.com/archive/2009/05/01/hiding-individual-menu-items-on-sharepoint-toolbars.aspx Download from codeplex/features

  • Anonymous
    August 05, 2009
    Open the form allitems.aspx in sp designer , under forms in the library. right click ,select  convert to xslt when finish the conversion, select the button. right clik the button. in properties , visble = false. voila, it works. If you want reverse the process , right click , and select recert to view of sharepoint. Gabriel Giraldo www.gjgsoftware.com sharepoint developer.

  • Anonymous
    August 09, 2009
    How to Remove or hide toolbars or commandbars ms access 2007

  • Anonymous
    August 23, 2009
    hi, excellent post, i have a requirement to remove NEW button from pages library ONLY. in all other library i NEW button is required. please help in this ..

  • Anonymous
    October 18, 2009
    Is there any possiblity to redirect the 'new' button to open my custom page or any other url. we do not want to write any custom event or extend the user control. in short. i want to relieve my administrators from programming.

  • Anonymous
    October 28, 2009
    Does anyone know how to remove the New Folder option on the list toolbar in WSS 2.0?