Click here to Skip to main content
15,891,850 members
Articles / Productivity Apps and Services / Sharepoint
Tip/Trick

SharePoint - Hiding Webpart div

Rate me:
Please Sign up or sign in to vote.
4.80/5 (2 votes)
20 Dec 2013CPOL 8.5K  
How to hide the HTML tags that surround a web part (SuppressWebPartChrome)

Introduction

When adding a DataFormWebPart web part in SharePoint, the following HTML is created by SharePoint when the page is rendered (or something similar to it).

ASP.NET
<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%" TOPLEVEL>
<TBODY>
<TR>
<TD vAlign=top>
<DIV id=WebPartWPQ2 allowDelete="false" 
OnlyForMePart="true" width="100%" HasPers="true" 
WebPartID="00000000-0000-0000-0000-000000000000">
<!-- html rendered by web part -->
</DIV></TD></TR></TBODY></TABLE>
<IMG alt="" src="/_layouts/images/blank.gif" 
width=590 height=1> 

Background

This code is tested in SharePoint 2007 with the DataFormWebPart.

Using the Code

In SharePoint Designer, add the SuppressWebPartChrome="True" property:

ASP.NET
// Example

<WebPartPages:DataFormWebPart SuppressWebPartChrome="True"  

When this property is set, the outside Table and Div tags will not be rendered by SharePoint.

This has been specifically helpful for .css renderings where embedded Divs and Tables can get thrown off.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect GuiangStar Corp
Canada Canada
.in the MS development game for 14+ years.

Comments and Discussions

 
-- There are no messages in this forum --