Disable “Add a Web Part” within a Web Part Zone

This is another self note article for me. I have been recently working on the page layouts and wanted to ensure web parts are added to the hidden web part zone only programmatically. I wanted to ensure end users are not aware of web part zone and hide adding, editing, or removing web parts interface for end users.

Add a web part interface

First I thought this might be tricky and may require some custom coding. Upon doing some quick research on web part zone properties and thanks to this wonderful MSDN forum entry, I came across “AllowLayoutChange” property which can be used to ensure “Add a Web Part” is hidden while page is in edit mode.

<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

<div>
<WebPartPages:WebPartZone runat=”server” AllowLayoutChange=”false” AllowPersonalization=”false” FrameType=”TitleBarOnly” ID=”MainZone” Title=”Main Zone” Orientation=”Vertical”><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
</div>

Reference: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpartzone.allowlayoutchange.aspx

Hope this quick tip would help someone.

Advertisements
This entry was posted in SharePoint 2010, SharePoint 2013. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s