WebPartZoneBase.EmptyZoneText 属性

定义

获取或设置在 WebPartZoneBase 控件不包含任何 WebPart 控件时出现的消息。Gets or sets a message that appears when a WebPartZoneBase control contains no WebPart controls.

public:
 virtual property System::String ^ EmptyZoneText { System::String ^ get(); void set(System::String ^ value); };
public override string EmptyZoneText { get; set; }
member this.EmptyZoneText : string with get, set
Public Overrides Property EmptyZoneText As String

属性值

一个字符串,其中包含在空区域中显示的消息。A string containing the message that appears in an empty zone. 默认的区域性特定字符串由 .NET Framework 提供。A default culture-specific string is supplied by the .NET Framework.

示例

下面的代码示例演示了 WebPartZone 控件上 EmptyZoneText 属性的声明性用法。The following code example demonstrates the declarative use of the EmptyZoneText property on a WebPartZone control. 有关完整的代码示例,包括代码隐藏源文件和包含此代码中区域的 .aspx 页面,请参阅 WebPartZoneBase 类概述。For the full code example, including the code-behind source file and the .aspx page that contains the zone in this code, see the WebPartZoneBase class overview.

请注意,在声明性标记中,EmptyZoneText 属性有一个分配给它的值。Notice that the EmptyZoneText property has a value assigned to it in the declarative markup. 此值将显示在 WebPartZone2中,将页面加载到浏览器后,将页面切换到设计显示模式,然后将显示日期的控件从 WebPartZone2 拖到 WebPartZone1中。This value will appear in WebPartZone2, after you load the page into a browser, switch the page into design display mode, and drag the control that displays the date from WebPartZone2 into WebPartZone1. 有关在 Web 部件页中更改显示模式的详细信息,请参阅演练:更改 Web 部件页上的显示模式For more information on changing display modes in a Web Parts page, see Walkthrough: Changing Display Modes on a Web Parts Page.

<asp:WebPartZone 
  ID="WebPartZone2"
  Runat="server" 
  DragHighlightColor="#00ff00"
  AllowLayoutChange="true"
  EmptyZoneText="Add WebParts to this empty Zone."
  BorderWidth="2"
  BorderColor="DarkBlue"
  BorderStyle="Dashed" 
  MenuLabelText="Verbs Menu" 
  MenuPopupImageUrl="label.gif" >
  <VerbStyle Font-Italic="true" />
  <MenuLabelStyle BackColor="Lime" BorderWidth="1"  />
  <MenuLabelHoverStyle Font-Bold="true" />
  <MenuVerbHoverStyle BackColor="LightGrey" />
  <MenuVerbStyle Font-Italic="true" /> 
  <ZoneTemplate>
    <asp:Label ID="Label1" Runat="server" Title="Date" />
  </ZoneTemplate>
</asp:WebPartZone>
<asp:WebPartZone 
  ID="WebPartZone2"
  Runat="server" 
  DragHighlightColor="#00ff00"
  AllowLayoutChange="true"
  EmptyZoneText="Add WebParts to this empty Zone."
  BorderWidth="2"
  BorderColor="DarkBlue"
  BorderStyle="Dashed" 
  MenuLabelText="Verbs Menu" 
  MenuPopupImageUrl="label.gif" >
  <VerbStyle Font-Italic="true" />
  <MenuLabelStyle BackColor="Lime" BorderWidth="1"  />
  <MenuLabelHoverStyle Font-Bold="true" />
  <MenuVerbHoverStyle BackColor="LightGrey" />
  <MenuVerbStyle Font-Italic="true" /> 
  <ZoneTemplate>
    <asp:Label ID="Label1" Runat="server" Title="Date" />
  </ZoneTemplate>
</asp:WebPartZone>

注解

EmptyZoneText 属性重写基属性,以区分未设置属性的情况,以及将属性设置为空字符串("")的情况。The EmptyZoneText property overrides the base property to distinguish between cases where the property has not been set and those where it has been set to an empty string ("").

如果尚未设置属性,并且区域不包含任何控件,则当 Web 部件页面进入显示模式(区域可见)时,会在空 WebPartZoneBase 控件中显示默认的区域性特定的短信。If the property has not been set and the zone contains no controls, when a Web Parts page enters into a display mode where the zone is visible, a default culture-specific text message appears in an empty WebPartZoneBase control. 如果 EmptyZoneText 属性值被有意设置为空字符串,则空区域中将不会显示任何短信。If the EmptyZoneText property value has intentionally been set to an empty string, then no text message appears in an empty zone.

适用于

另请参阅