WebPartChrome.CreateWebPartChromeStyle Method

Note: This method is new in the .NET Framework version 2.0.

Creates the style object that supplies style attributes for each WebPart control rendered by the WebPartChrome object.

Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in system.web.dll)

protected:
virtual Style^ CreateWebPartChromeStyle (
	WebPart^ webPart, 
	PartChromeType chromeType
)
protected Style CreateWebPartChromeStyle (
	WebPart webPart, 
	PartChromeType chromeType
)
protected function CreateWebPartChromeStyle (
	webPart : WebPart, 
	chromeType : PartChromeType
) : Style

Parameters

webPart

The control that is currently being rendered.

chromeType

The type of chrome for a particular control; one of the PartChromeType enumeration values.

Return Value

A Style that contains style attributes for the webPart.

The CreateWebPartChromeStyle method creates a Style object that is used by the WebPartChrome object to render a WebPart control. The default method creates style attributes based on the PartChromeType property value of the WebPart control referenced in the webPart parameter.

A special situation occurs when a WebPart control is selected. If the page is in a page display mode where controls can be selected, and the current control is actually selected, the default CreateWebPartChromeStyle method also merges the style information of the control with the style information from the SelectedPartChromeStyle property.

Notes to Inheritors If you inherit from the WebPartChrome class, you can optionally override the CreateWebPartChromeStyle method, and merge the style information from the base method with custom style attributes that you want to add. For a demonstration, see the code in the Example section.

This code example demonstrates use of the CreateWebPartChromeStyle method. For the full code required to run the example, see the Example section of the WebPartChrome class overview topic.

The following section from the code example demonstrates how to override the CreateWebPartChromeStyle method. Notice that it first retrieves the style information created by the base method, and then modifies the style information by changing the font used for the WebPart control being rendered.

No code example is currently available or this language may not be supported.

If you load the Web page in a browser, you can see that the font used in the WebPart controls is the one specified in the overridden CreateWebPartChromeStyle method.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: