WebPartChrome Constructor (WebPartZoneBase^, WebPartManager^)
Initializes a new instance of the control.
Assembly: System.Web (in System.Web.dll)
Parameters
- zone
-
Type:
System.Web.UI.WebControls.WebParts::WebPartZoneBase^
The associated WebPartZoneBase control.
- manager
-
Type:
System.Web.UI.WebControls.WebParts::WebPartManager^
The WebPartManager control on the current page.
| Exception | Condition |
|---|---|
| ArgumentNullException | zone is null. |
The WebPartChrome initializes a new instance of the WebPartChrome class. It is used primarily by a WebPartZoneBase zone in its CreateWebPartChrome method to create an instance of the WebPartChrome object that handles the chrome rendering and any custom rendering for WebPart controls in the zone.
The following code example demonstrates two things. First, it creates a new instance of the custom class MyWebPartChrome by overriding the CreateWebPartChrome method in a derived WebPartZoneBase zone called MyZone. Second, in the constructor of the MyWebPartChrome class, it assigns the objects in the parameters of the constructor to private fields that can be used within the class. This example thus gives you a way to access the associated zone and WebPartManager object even in the constructor, before the Zone and WebPartManager properties are accessible. Finally, note that for the constructor to work, the base constructor must also be invoked as part of the method declaration.
The following code contains the two custom classes. For the full code required to run the example, including the Web page to host these controls, see the Example section of the WebPartChrome class overview topic.
Available since 2.0