Blog Categories

Subscribe to RSS feed


No Chrome for Web Parts outside the zone.

Recently while adding a web part to a page layout, I came across a weird behavior. Whenever I added a web part to a page layout in the web part zone, the chrome showed up fine but when I added the web part outside the zone and published the page layout the chrome would not be displayed.

Resolution: I was using the System.Web.UI.WebControls.WebParts.WebPart class as the base class for my web part. When I switched the base class to Microsoft.SharePoint.WebPartPages.WebPart the chrome starting showing even when the web part was outside the zone.

This MSDN article recommends using the .NET framework Web Part base class. Even though its use is recommended the class does not render the chrome outside the zone like one would expect it too.

Excerpt from the article:

When creating new Web Parts, you have the option of creating Web Parts that inherit from System.Web.UI.WebControls.WebParts.WebPart (recommended) or Microsoft.SharePoint.WebPartPages.WebPart. The SharePoint FoundationWebPart class exists primarily for the purpose of backward compatibility and to provide a small set of features that are not available in the System.Web.UI.WebControls.WebParts.WebPart class.

The set of features provided exclusively by Microsoft.SharePoint.WebPartPages.WebPart is as follows:

  • Cross page connections

  • Connections between Web Parts that are outside of a zone

  • Client-side connections (Web Part Page Services Component)

  • Data caching infrastructure, including the ability to cache to the database

After digging a bit deeper, it appears that the WebPartChrome class is responsible for rendering the chrome. The WebPartZoneBase class has a method called RenderBody which invokes the RenderWebPart method of WebPartChrome class. When the web part is outside the zone, the chrome will not be rendered as the System.Web.UI.WebControls.WebParts.WebPart class does not render the chrome. But the Microsoft.SharePoint.WebPartPages.WebPart class has overridden the Render method and invokes methods on the Chrome Helper class which renders the chrome even when the web part is outside the zone.

protected override void Render(HtmlTextWriter writer)
    SPChrome.SPChromeHelper helper = null;
    if ((this.WebPartZone == null) && !this.SuppressWebPartChrome)
        helper = new SPChrome.SPChromeHelper(null, WebPartManager.GetCurrentWebPartManager(this.Page), this.Web, this._inDesign);
    if ((this.WebPartZone == null) && !this.SuppressWebPartChrome)

Here you can see that the Render method checks if the zone is null and if the property *SuppressWebPartChrome is false and then renders the chrome. The Render method on the System.Web.UI.WebControls.WebParts.WebPart class does not implement this functionality.

*SuppressWebPartChrome: This property is part of the Microsoft.SharePoint.WebPartPages.WebPart class and not of the .Net framework Web Part class.

.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode, .ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode pre
{font-size:small;color:black;font-family:consolas, "Courier New", courier, monospace;background-color:#ffffff;}
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode pre
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .rem
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .kwrd
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .str
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .op
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .preproc
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .asp
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .html
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .attr
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .alt
.ExternalClass44551836581F4C888C6191DF57BE7F8E .csharpcode .lnum

Leave a Reply