WebPartChrome.Zone Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a reference to the associated WebPartZoneBase zone.
protected:
property System::Web::UI::WebControls::WebParts::WebPartZoneBase ^ Zone { System::Web::UI::WebControls::WebParts::WebPartZoneBase ^ get(); };
protected System.Web.UI.WebControls.WebParts.WebPartZoneBase Zone { get; }
member this.Zone : System.Web.UI.WebControls.WebParts.WebPartZoneBase
Protected ReadOnly Property Zone As WebPartZoneBase
Property Value
A reference to a WebPartZoneBase that is associated with the WebPartChrome.
Examples
This code example demonstrates use of the Zone property. For the full code required to run the example, see the Example section of the WebPartChrome class overview topic.
The following code example uses the Zone property to determine whether the zone currently associated with the WebPartChrome object is a zone of type MyZone
. If so, the control's contents are rendered. This code would prevent the custom WebPartChrome object from working with any other zone besides the one designed to create an instance of it.
protected override void RenderPartContents(HtmlTextWriter writer,
WebPart part)
{
if (part == this.WebPartManager.SelectedWebPart)
HttpContext.Current.Response.Write("<span>Not rendered</span>");
else
if(this.Zone.GetType() == typeof(MyZone))
part.RenderControl(writer);
}
Protected Overrides Sub RenderPartContents _
(ByVal writer As HtmlTextWriter, ByVal part As WebPart)
If part Is Me.WebPartManager.SelectedWebPart Then
HttpContext.Current.Response.Write("<span>Not rendered</span>")
Else
If (Me.Zone.GetType() Is GetType(MyZone)) Then
part.RenderControl(writer)
End If
End If
End Sub
If you load the Web page in a browser, the content of each control is rendered normally. You can switch the page into design mode by selecting Design in the Display Mode drop-down list control. If you drag one of the controls into the empty zone labeled WebPartZone2, its contents are rendered differently, because the custom WebPartChrome object is not being used for the rendering. This is the same effect that you would achieve if you tried to use the custom WebPartChrome class with any other zone besides the MyZone
class, because of the preceding source code.
Remarks
The Zone property provides a reference to the WebPartZoneBase zone that contains the controls for which the WebPartChrome object provides rendering.
Applies to
See also
Athugasemdir
https://aka.ms/ContentUserFeedback.
Væntanlegt: Á árinu 2024 munum við hætta með GitHub-mál sem ábendingaleið fyrir efni og skipta því út fyrir nýtt ábendingakerfi. Frekari upplýsingar er að finna hér:Senda inn og skoða endurgjöf fyrir