WebZone.EmptyZoneText Property

 

Gets or sets a message that appears when a zone contains no controls.

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

public virtual string EmptyZoneText { get; set; }

Property Value

Type: System.String

A string containing the message that appears in an empty zone. A default culture-specific string is supplied by the .NET Framework.

The text in the EmptyZoneText property appears when there are no controls in a zone, and the zone is in one of the personalization modes, such as edit, design, or catalog mode.

System_CAPS_noteNote

When a zone enters one of the personalization modes that would allow personalization changes to be made to the zone's contents, the WebPartManager control sets the WebPartDisplayMode.AllowPageDesign property value to true on the display mode object referenced in its WebPartManager.DisplayMode property.

The following code example demonstrates the use of the EmptyZoneText property. Note that there are two zones in the declarative markup, and the second <asp:webpartzone> element is empty.

<%@ page language="C#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server">
        <zonetemplate>
          <asp:Calendar ID="cal1" Runat="server" Title="My Calendar" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:webpartzone
      id="WebPartZone2"
      runat="server" 
      EmptyZoneText="No controls in this zone.">
    </asp:webpartzone>
  </form>
</body>
</html>

In a browser, you can switch to design mode to see the text supplied for the EmptyZoneText property displayed in the empty zone. For details on how to change page display modes, see Walkthrough: Changing Display Modes on a Web Parts Page.

.NET Framework
Available since 2.0
Return to top
Show: