Last month, I came across a requirement where I need to hide Upload toolbar button on one of our forms library. I tried to find on net, and got some clues how to do this. Adding a custom control under c:\Program Files\Common Files\Microsoft shared\Web service extensions\12\Template\CONTROLTEMPLATES, this can be done.
But using this way, It hides toolbar buttons for all of the document library and Forms library. Following is the workaround to hide toolbar buttons on specific forms library.
Step 1: Design a InfoPath Form with some controls on it.
Step 2: Publish InfoPath form as a Site Content Type “MyCustomContentType” on Forms Template Library
Step 3: Using Visual Studio Sharepoint tools, Create custom list definition for Forms Library. Tool used is Visual Studio 2005 extensions for Windows SharePoint Services 3.0, Version 1.0) Tools for developing custom SharePoint applications.
Step 4: Under Schema.Xml add attribute ToolbarTemplate=”myToolBarID” to <View BaseViewID="1" > element as follows
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,All_Tasks;" DefaultView="TRUE" MobileView="True" MobileDefaultView="False" ToolbarTemplate="myToolBarID” SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/issues.png" Url="AllItems.aspx>
Step 5: Build the custom form library definition and deploy it/
Step 6: Create a forms library based on this newly created definition.
Step 7: Toolbar for the newly created forms library will be missing.
Step 8: Save following code snippet as MyCustomFormLibToolBar.ascx into c:\Program Files\Common Files\Microsoft Shared\Web Service Extensions\12\Templates\CONTROLTEMPLATES
<%@ 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" %> <Template_Buttons> <SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/> |
Step 9: IISReset
Step 10: Toolbar for the newly created Forms library is available.
Step 11: Open Advance Settings for the Forms Library settings
Step 12: Check Allow multiple content types, Open as Web Page.
Step 13: Select Add existing content type, and add “MyCustomContentType”.
The similar ascx control can be used to hide or remove toolbar buttons on specific SharePoint List, Document Library as well.
No comments:
Post a Comment