Web Parts chrome refers to the peripheral user interface (UI) elements that frame each WebPart control or server control contained in a WebPartZoneBase zone. The chrome for a control includes its border, its title bar, and the icons, title text, and verbs menu that appear within the title bar. The appearance of the chrome is set at the zone level, and applies to all the server controls in the zone.
The Web Parts control set uses the WebPartChrome class to render the chrome for WebPart controls. Additionally, this class provides a way for developers to customize the rendering of any individual section (such as the header or footer) of the WebPart controls in a WebPartZoneBase zone without having to handle all the rendering for those controls. For example, you can override the CreateWebPartChromeStyle method to customize some specific style attributes applied to the WebPartZoneBase zone, but you can rely on the default rendering to handle the rest.
The WebPartChrome class contains several important methods that are useful when you want to override the rendering of WebPart controls. One is the CreateWebPartChromeStyle method, which enables you to change the style attributes of the Style object associated with the WebPartChrome object used to render a control. Another is the WebPartChrome constructor, which you use when you override the CreateWebPartChrome method in a custom WebPartZoneBase class to create an instance of your custom WebPartChrome object. Another useful method is the RenderPartContents method, which you can use to control the rendering of the content area of controls in a zone (as opposed to chrome elements such as headers, footers, and title bars). The GetWebPartVerbs method enables you to exclude certain verbs from being rendered, if for some reason you do not want users to see those verbs in the UI. Finally, if you want complete programmatic control over all aspects of rendering the WebPart controls, you can override the RenderWebPart method.
Several properties of the WebPartChrome class are also useful. The Zone and WebPartManager properties provide references to the zone associated with the WebPartChrome object and the current WebPartManager instance, respectively.
Notes to Inheritors
Inherit from the
WebPartChrome class when you want to override the default rendering of certain sections of
WebPart or server controls. You can optionally override the
CreateWebPartChromeStyle method, the
GetWebPartVerbs method, and especially the
RenderPartContents or
RenderWebPart methods, to customize the rendering. To use your custom
WebPartChrome class for the
WebPart controls in a zone, develop a custom zone derived from the
WebPartZoneBase class, and override its
CreateWebPartChrome method. For details on how to use a child
WebPartChrome object in a zone, see the Example section.