Welcome to MSDN Blogs Sign in | Join | Help

Dipper Park

Technical Blogs focus on MOSS 2007, Unified Messaging, Microsoft CRM and BI.
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>

 

Posted: Thursday, October 05, 2006 8:43 AM by Chris Tao

Comments

Thomas Goddard said:

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!

# December 22, 2006 1:05 AM

sukumar said:

Thank you very very much this was helpfull

# April 3, 2007 5:45 AM

Cinek said:

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

# April 6, 2007 7:45 AM

vikram said:

How can I add new buttons on the toolbar?

# June 12, 2007 4:42 AM

saba said:

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

# June 30, 2007 3:18 AM

KGR said:

Thanks, Really Helpful

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

# July 9, 2007 10:13 AM

René van der Enden said:

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

# July 27, 2007 3:55 AM

Mark said:

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>

# August 9, 2007 3:04 PM

Pinku said:

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.

# September 10, 2007 4:06 PM

Kevin said:

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!

# September 12, 2007 11:00 AM

shigeki said:

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.

# September 20, 2007 6:09 AM

Bjørn Stærk said:

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).  

# September 25, 2007 8:51 AM

shigeki said:

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!

# September 26, 2007 9:44 PM

Magnus said:

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. :\

# September 28, 2007 8:43 AM

shigeki said:

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".

# October 1, 2007 9:56 PM

aasmag said:

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

# October 8, 2007 7:11 AM

Ibu said:

Hi Bjørn Stærk,

Thanks for your help to hide the elements in the New menu.You made my day. When i am creating a custom control for NewMenu how can i add custom action through feature in my custom new menu.I tried with all the possible Location and groupid but the feature did not identify my custom menu. what should be the location for my custom menu instead of Microsft.SharePoint.StandardMenu. Please let me know if you have any input.

# October 16, 2007 4:42 PM

David Naas said:

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

# November 5, 2007 5:34 PM

David Naas said:

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.

# November 6, 2007 10:26 AM

Bill said:

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?

# November 14, 2007 8:53 AM

Putra said:

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

# November 22, 2007 12:04 AM

Darshan said:

Hi,

How to hide the same with given sub site.

# December 11, 2007 2:06 AM

jatuphum said:

Hi,

I want to remove "Actions" and "Uploads" only if user is "Contributor" role.

Can this solution do?

Thank you very much.

# January 2, 2008 1:15 PM

Rupali Kothawade said:

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.

# January 28, 2008 3:59 AM

john said:

I have a similar question as Rupali...how can I do this with other list types?  i.e. Announcements or Custom List.

# February 13, 2008 4:22 PM

anne said:

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

# February 14, 2008 6:46 AM

aditya said:

Hi,

i want to know how can i hide/remove the multiple upload button from the upload menu.

# February 14, 2008 5:13 PM

asfar said:

same problem here, need to remove/hide the single upload button from the upload menu. no luck on any trials.

anyone can help?

# February 22, 2008 9:50 PM

asfar said:

# February 22, 2008 10:57 PM

Shanea said:

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

# April 15, 2008 2:30 PM

Novotronix Blog said:

Hiding toolbar menu items in a Sharepoint list

# April 16, 2008 7:20 AM

Ketul said:

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/

# June 16, 2008 11:45 AM

First Hand said:

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

# June 17, 2008 8:41 AM

.neting in the free world said:

If you would like to have some paragraphs translated from Polish to English please leave a comment. Post

# September 7, 2008 5:28 PM

RachelTerry said:

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

# September 16, 2008 1:33 PM

george li said:

I test this code,but it's not work...

# November 10, 2008 9:55 PM

Awanish said:

How to hide New Menu of Custom List

# November 27, 2008 4:58 AM

Arokiasamy said:

i need to remove upload and settings menu in form library tool bar.

# December 15, 2008 11:54 PM

TMac said:

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

# January 12, 2009 11:17 AM

Ayman El-Hattab said:

I have done that using javascript ..

check this article ..

http://www.codeproject.com/KB/sharepoint/sharepoint-customization.aspx

# January 24, 2009 4:11 PM

Tanmay Bari said:

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!

# February 3, 2009 6:34 AM

Saurabh said:

Hi can we do this from Schema.xml

# February 11, 2009 1:24 AM

Gunnar Peipman's ASP.NET blog said:

SharePoint Customizing SharePoint Context Menus Hidden SharePoint Lists, Fields, and other Advanced List

# April 6, 2009 3:58 PM

vamsi said:

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

# April 10, 2009 5:54 AM

Rajdeep said:

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.

# April 16, 2009 3:40 PM

CG said:

# June 9, 2009 5:35 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker