CatalogZone 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
作為在網頁上裝載 CatalogPart 控制項之網頁組件控制項集合中的主要控制項。
public ref class CatalogZone : System::Web::UI::WebControls::WebParts::CatalogZoneBase
public class CatalogZone : System.Web.UI.WebControls.WebParts.CatalogZoneBase
type CatalogZone = class
inherit CatalogZoneBase
Public Class CatalogZone
Inherits CatalogZoneBase
- 繼承
範例
下列程式碼範例示範控制項的 CatalogZone 宣告式和程式設計用法。 程式碼範例有四個部分:
使用者控制項,可讓您變更網頁上的顯示模式。
具有自訂 CatalogZone 控制項原始程式碼的檔案,以及目錄匯入並新增至網頁的自訂 WebPart 控制項。
宣告使用者控制項和自訂 CatalogZone 控制項的網頁。
如何執行範例的說明。
此程式碼範例的第一個部分是使用者控制項,可讓使用者變更網頁上的顯示模式。 如需此控制項中原始程式碼顯示模式和描述的詳細資訊,請參閱逐步解說 :變更網頁元件頁面上的顯示模式。
<%@ control language="C#" classname="DisplayModeMenuCS"%>
<script runat="server">
// Use a field to reference the current WebPartManager.
WebPartManager _manager;
void Page_Init(object sender, EventArgs e)
{
Page.InitComplete += new EventHandler(InitComplete);
}
void InitComplete(object sender, System.EventArgs e)
{
_manager = WebPartManager.GetCurrentWebPartManager(Page);
String browseModeName = WebPartManager.BrowseDisplayMode.Name;
// Fill the dropdown with the names of supported display modes.
foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes)
{
String modeName = mode.Name;
// Make sure a mode is enabled before adding it.
if (mode.IsEnabled(_manager))
{
ListItem item = new ListItem(modeName, modeName);
DisplayModeDropdown.Items.Add(item);
}
}
// If shared scope is allowed for this user, display the scope-switching
// UI and select the appropriate radio button for the current user scope.
if (_manager.Personalization.CanEnterSharedScope)
{
Panel2.Visible = true;
if (_manager.Personalization.Scope == PersonalizationScope.User)
RadioButton1.Checked = true;
else
RadioButton2.Checked = true;
}
}
// Change the page to the selected display mode.
void DisplayModeDropdown_SelectedIndexChanged(object sender, EventArgs e)
{
String selectedMode = DisplayModeDropdown.SelectedValue;
WebPartDisplayMode mode = _manager.SupportedDisplayModes[selectedMode];
if (mode != null)
_manager.DisplayMode = mode;
}
// Set the selected item equal to the current display mode.
void Page_PreRender(object sender, EventArgs e)
{
ListItemCollection items = DisplayModeDropdown.Items;
int selectedIndex =
items.IndexOf(items.FindByText(_manager.DisplayMode.Name));
DisplayModeDropdown.SelectedIndex = selectedIndex;
}
// Reset all of a user's personalization data for the page.
protected void LinkButton1_Click(object sender, EventArgs e)
{
_manager.Personalization.ResetPersonalizationState();
}
// If not in User personalization scope, toggle into it.
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (_manager.Personalization.Scope == PersonalizationScope.Shared)
_manager.Personalization.ToggleScope();
}
// If not in Shared scope, and if user is allowed, toggle the scope.
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
if (_manager.Personalization.CanEnterSharedScope &&
_manager.Personalization.Scope == PersonalizationScope.User)
_manager.Personalization.ToggleScope();
}
</script>
<div>
<asp:Panel ID="Panel1" runat="server"
Borderwidth="1"
Width="230"
BackColor="lightgray"
Font-Names="Verdana, Arial, Sans Serif" >
<asp:Label ID="Label1" runat="server"
Text=" Display Mode"
Font-Bold="true"
Font-Size="8"
Width="120"
AssociatedControlID="DisplayModeDropdown"/>
<asp:DropDownList ID="DisplayModeDropdown" runat="server"
AutoPostBack="true"
Width="120"
OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged" />
<asp:LinkButton ID="LinkButton1" runat="server"
Text="Reset User State"
ToolTip="Reset the current user's personalization data for the page."
Font-Size="8"
OnClick="LinkButton1_Click" />
<asp:Panel ID="Panel2" runat="server"
GroupingText="Personalization Scope"
Font-Bold="true"
Font-Size="8"
Visible="false" >
<asp:RadioButton ID="RadioButton1" runat="server"
Text="User"
AutoPostBack="true"
GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged" />
<asp:RadioButton ID="RadioButton2" runat="server"
Text="Shared"
AutoPostBack="true"
GroupName="Scope"
OnCheckedChanged="RadioButton2_CheckedChanged" />
</asp:Panel>
</asp:Panel>
</div>
<%@ control language="vb" classname="DisplayModeMenuVB"%>
<script runat="server">
' Use a field to reference the current WebPartManager.
Dim _manager As WebPartManager
Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
AddHandler Page.InitComplete, AddressOf InitComplete
End Sub
Sub InitComplete(ByVal sender As Object, ByVal e As System.EventArgs)
_manager = WebPartManager.GetCurrentWebPartManager(Page)
Dim browseModeName As String = WebPartManager.BrowseDisplayMode.Name
' Fill the dropdown with the names of supported display modes.
Dim mode As WebPartDisplayMode
For Each mode In _manager.SupportedDisplayModes
Dim modeName As String = mode.Name
' Make sure a mode is enabled before adding it.
If mode.IsEnabled(_manager) Then
Dim item As New ListItem(modeName, modeName)
DisplayModeDropdown.Items.Add(item)
End If
Next mode
' If shared scope is allowed for this user, display the scope-switching
' UI and select the appropriate radio button for the current user scope.
If _manager.Personalization.CanEnterSharedScope Then
Panel2.Visible = True
If _manager.Personalization.Scope = PersonalizationScope.User Then
RadioButton1.Checked = True
Else
RadioButton2.Checked = True
End If
End If
End Sub
' Change the page to the selected display mode.
Sub DisplayModeDropdown_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As EventArgs)
Dim selectedMode As String = DisplayModeDropdown.SelectedValue
Dim mode As WebPartDisplayMode = _
_manager.SupportedDisplayModes(selectedMode)
If Not (mode Is Nothing) Then
_manager.DisplayMode = mode
End If
End Sub
' Set the selected item equal to the current display mode.
Sub Page_PreRender(ByVal sender As Object, ByVal e As EventArgs)
Dim items As ListItemCollection = DisplayModeDropdown.Items
Dim selectedIndex As Integer = _
items.IndexOf(items.FindByText(_manager.DisplayMode.Name))
DisplayModeDropdown.SelectedIndex = selectedIndex
End Sub
' Reset all of a user's personalization data for the page.
Protected Sub LinkButton1_Click(ByVal sender As Object, _
ByVal e As EventArgs)
_manager.Personalization.ResetPersonalizationState()
End Sub
' If not in User personalization scope, toggle into it.
Protected Sub RadioButton1_CheckedChanged(ByVal sender As Object, _
ByVal e As EventArgs)
If _manager.Personalization.Scope = PersonalizationScope.Shared Then
_manager.Personalization.ToggleScope()
End If
End Sub
' If not in Shared scope, and if user is allowed, toggle the scope.
Protected Sub RadioButton2_CheckedChanged(ByVal sender As Object, _
ByVal e As EventArgs)
If _manager.Personalization.CanEnterSharedScope AndAlso _
_manager.Personalization.Scope = PersonalizationScope.User Then
_manager.Personalization.ToggleScope()
End If
End Sub
</script>
<div>
<asp:Panel ID="Panel1" runat="server"
Borderwidth="1"
Width="230"
BackColor="lightgray"
Font-Names="Verdana, Arial, Sans Serif" >
<asp:Label ID="Label1" runat="server"
Text=" Display Mode"
Font-Bold="true"
Font-Size="8"
Width="120"
AssociatedControlID="DisplayModeDropdown"/>
<asp:DropDownList ID="DisplayModeDropdown" runat="server"
AutoPostBack="true"
Width="120"
OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged" />
<asp:LinkButton ID="LinkButton1" runat="server"
Text="Reset User State"
ToolTip="Reset the current user's personalization data for the page."
Font-Size="8"
OnClick="LinkButton1_Click" />
<asp:Panel ID="Panel2" runat="server"
GroupingText="Personalization Scope"
Font-Bold="true"
Font-Size="8"
Visible="false" >
<asp:RadioButton ID="RadioButton1" runat="server"
Text="User"
AutoPostBack="true"
GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged" />
<asp:RadioButton ID="RadioButton2" runat="server"
Text="Shared"
AutoPostBack="true"
GroupName="Scope"
OnCheckedChanged="RadioButton2_CheckedChanged" />
</asp:Panel>
</asp:Panel>
</div>
程式碼範例的第二個部分包含自訂 CatalogZone 和 WebPart 控制項的程式碼。 控制項的程式 CatalogZone 代碼示範如何繼承自 類別, CatalogZone 並在建構函式中設定一些預設屬性值來自訂其屬性。 原始程式碼也會示範如何建立名為 的 TextDisplayWebPart
自訂 WebPart 類別。 這是與 相關聯的控制項。您將在此程式碼範例中匯入的 WebPart 描述檔案。 使用 ImportCatalogPart 網頁上的 控制項匯入描述檔案之後,您就可以將控制項新增 TextDisplayWebPart
至頁面,如描述檔案中所指定的完整預先設定。
若要執行程式碼範例,您必須編譯此原始程式碼。 您可以明確地編譯它,並將產生的元件放在網站的 Bin 資料夾或全域組件快取中。 或者,您也可以將原始程式碼放在月臺的 App_Code 資料夾中,在執行時間會動態編譯原始程式碼。 此程式碼範例會使用動態編譯,因此如果您想要以這種方式執行範例,請將原始程式碼檔案命名為 ,並將它新增至 Web 應用程式根目錄的App_Code子資料夾。 如需示範這兩種編譯方法的逐步解說,請參閱逐步解說 :開發和使用自訂 Web 服務器控制項。
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace Samples.AspNet.CS.Controls
{
// Create a customized CatalogZone control by setting
// some properties in the constructor.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class MyCatalogZone : CatalogZone
{
public MyCatalogZone()
{
this.HeaderText = "My Company Catalog";
this.HeaderCloseVerb.Text = "Close Catalog";
this.CloseVerb.Text = "Close Catalog";
}
}
// Create a custom WebPart control to add to a WebPartZone.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class TextDisplayWebPart : WebPart
{
private String _contentText = null;
TextBox input;
Label DisplayContent;
Literal lineBreak;
[Personalizable(), WebBrowsable]
public String ContentText
{
get { return _contentText; }
set { _contentText = value; }
}
protected override void CreateChildControls()
{
Controls.Clear();
DisplayContent = new Label();
DisplayContent.BackColor = Color.LightBlue;
DisplayContent.Text = this.ContentText;
this.Controls.Add(DisplayContent);
lineBreak = new Literal();
lineBreak.Text = @"<br />";
Controls.Add(lineBreak);
input = new TextBox();
this.Controls.Add(input);
Button update = new Button();
update.Text = "Set Label Content";
update.Click += new EventHandler(this.submit_Click);
this.Controls.Add(update);
}
private void submit_Click(object sender, EventArgs e)
{
// Update the label string.
if (!string.IsNullOrEmpty(input.Text))
{
_contentText = input.Text + @"<br />";
input.Text = String.Empty;
DisplayContent.Text = this.ContentText;
}
}
}
}
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Namespace Samples.AspNet.VB.Controls
' Create a custom CatalogZone control by setting some
' properties in the constructor.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyCatalogZone
Inherits CatalogZone
Public Sub New()
Me.HeaderText = "My Company Catalog"
Me.HeaderCloseVerb.Text = "Close Catalog"
Me.CloseVerb.Text = "Close Catalog"
End Sub
End Class
' Create a custom WebPart to add to a WebPartZone.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class TextDisplayWebPart
Inherits WebPart
Private _contentText As String = Nothing
Private _fontStyle As String = Nothing
Private input As TextBox
Private DisplayContent As Label
Private lineBreak As Literal
<Personalizable(), WebBrowsable()> _
Public Property ContentText() As String
Get
Return _contentText
End Get
Set(ByVal value As String)
_contentText = value
End Set
End Property
Protected Overrides Sub CreateChildControls()
Controls.Clear()
DisplayContent = New Label()
DisplayContent.BackColor = Color.LightBlue
DisplayContent.Text = Me.ContentText
Me.Controls.Add(DisplayContent)
lineBreak = New Literal()
lineBreak.Text = "<br />"
Controls.Add(lineBreak)
input = New TextBox()
Me.Controls.Add(input)
Dim update As New Button()
update.Text = "Set Label Content"
AddHandler update.Click, AddressOf Me.submit_Click
Me.Controls.Add(update)
End Sub
Private Sub submit_Click(ByVal sender As Object, _
ByVal e As EventArgs)
' Update the label string.
If input.Text <> String.Empty Then
_contentText = input.Text + "<br />"
input.Text = String.Empty
DisplayContent.Text = Me.ContentText
End If
End Sub
End Class
End Namespace
程式碼範例的第三個部分是包含控制項的網頁。 它包含使用者控制項的指示詞,以及另一個 Register
用於具有自訂控制項的來源檔案。 請注意,在第二個指示詞中,它不會命名元件,因為此範例不會使用元件,所以它會使用動態編譯搭配App_Code子資料夾中放置的原始程式碼。 網頁會 WebPartZone 宣告控制項,並在其子 <zonetemplate>
元素內宣告 BulletedList 控制項。 雖然這是標準 ASP.NET 控制項,但它在執行時間會有完整的 Web 元件功能,因為 WebPartManager 控制項會將放置於 物件中的任何伺服器控制項包裝在 中 WebPartZoneGenericWebPart ,讓其他伺服器控制項可以參與 Web 元件應用程式。 此區域中也宣告為名為 的 TextDisplayWebPart
自訂 WebPart 控制項。 請注意,這個控制項的 屬性已宣告于該控制項 ExportMode="All"
上。 這可讓您匯出 。包含控制項屬性值的 WebPart 描述檔案,其他使用者可以匯入該檔案,以將預先設定的控制項新增至其他網頁。
注意
若要讓使用者 Web 元件應用程式匯出控制項的描述檔 WebPart ,您也必須將 屬性新增 enableExport="true"
至 <webParts>
元素 (,這是Web.config檔案中專案) 的子 <system.web>
系,以啟用 Web 應用程式中的匯出功能。 預設會停用匯出,因此如果您尚未為應用程式啟用匯出,請編輯Web.config檔案,然後立即執行。
網頁也會宣告自訂 CatalogZone 控制項,並在其中 <zonetemplate>
宣告包含 ImportCatalogPart 控制項的專案。 使用者會在執行時間使用此控制項來匯入 。自訂 WebPart 控制項的 WebPart 描述檔案。
<%@ Page Language="C#" %>
<%@ register TagPrefix="uc1"
TagName="DisplayModeMenuCS"
Src="DisplayModeMenuCS.ascx" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.CS.Controls" %>
<!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 runat="server">
<title>Untitled Page</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:BulletedList
ID="BulletedList1"
Runat="server"
DisplayMode="HyperLink"
Title="Favorite Links" >
<asp:ListItem Value="http://msdn.microsoft.com">
MSDN
</asp:ListItem>
<asp:ListItem Value="http://www.asp.net">
ASP.NET
</asp:ListItem>
<asp:ListItem Value="http://www.msn.com">
MSN
</asp:ListItem>
</asp:BulletedList>
<aspsample:textdisplaywebpart id="wp1" runat="server"
Title="My Text Display WebPart" />
</ZoneTemplate>
</asp:WebPartZone>
<aspSample:MyCatalogZone ID="CatalogZone1" runat="server">
<ZoneTemplate>
<asp:ImportCatalogPart id="ImportCatalogPart1"
runat="server" />
</ZoneTemplate>
</aspSample:MyCatalogZone>
</form>
</body>
</html>
<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1"
TagName="DisplayModeMenuVB"
Src="DisplayModeMenuVB.ascx" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.VB.Controls" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:WebPartManager ID="WebPartManager1" runat="server" />
<uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" />
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<asp:BulletedList
ID="BulletedList1"
Runat="server"
DisplayMode="HyperLink"
Title="Favorite Links" >
<asp:ListItem Value="http://msdn.microsoft.com">
MSDN
</asp:ListItem>
<asp:ListItem Value="http://www.asp.net">
ASP.NET
</asp:ListItem>
<asp:ListItem Value="http://www.msn.com">
MSN
</asp:ListItem>
</asp:BulletedList>
<aspsample:textdisplaywebpart id="wp1" runat="server"
Title="My Text Display WebPart" />
</ZoneTemplate>
</asp:WebPartZone>
<aspSample:MyCatalogZone ID="CatalogZone1" runat="server">
<ZoneTemplate>
<asp:ImportCatalogPart id="ImportCatalogPart1"
runat="server" />
</ZoneTemplate>
</aspSample:MyCatalogZone>
</form>
</body>
</html>
現在執行程式碼範例。 在瀏覽器中載入網頁。 第一個步驟是匯出 。控制項的 TextDisplayWebPart
WebPart 描述檔案。 按一下自訂控制項上的動詞功能表, (標題列中的向下箭號) ,然後按一下 [ 匯出]。 請依照指示儲存控制項的描述檔。 開啟 。編輯器中的 WebPart 描述檔案,並編輯標題屬性文字的值。 <property>
尋找具有 屬性 name="Title"
的專案,並編輯開頭和結尾 <property>
標籤之間所包含的標題文字。 現在關閉網頁,然後在編輯器中編輯頁面來源。 <aspSample:TextDisplayWebPart>
刪除控制項宣告專案,然後儲存並關閉檔案。
在瀏覽器中再次載入網頁。 TextDisplayWebPart
控制項不應該出現,因為您移除了控制項。 使用 [ 顯示模式 ] 下拉式清單控制項,然後選取 [ 目錄 ] 將頁面切換為目錄模式。 請注意,自訂 CatalogZone 控制項隨即出現,以及 ImportCatalogPart 控制項。 按一下 [ 流覽] 按鈕以找出 。您針對 控制項匯出的 TextDisplayWebPart
WebPart 描述檔案。 您可以按一下 [上傳],選取匯入控制項旁的核取方塊,然後按一下 [ 新增 ] 將其新增至頁面。 按一下 [關閉類別目錄 ] 以將頁面傳回一般瀏覽模式。 匯入的控制項現在應該會出現在頁面中,而出現在控制項標題列中的標題應該是您新增至 的標題文字。WebPart 描述檔案。
備註
在網頁元件控制項集內,區域是網頁中包含網頁元件控制項的區域。 網頁元件區域是由區域控制項所建立,這是設計成包含其他控制項的 CompositeControl 型別。 區域的主要功能是配置它所包含的控制項,並提供這些控制項的通用使用者介面 (UI) 。 如需區域及其在 Web 元件應用程式中使用方式的一般資訊,請參閱基 WebZone 類和 Web 元件控制項集概觀。
網頁元件控制項的主要功能是可讓使用者根據喜好設定修改 (或個人化) 網頁,並儲存其個人化設定以供未來的瀏覽器會話使用。 修改網頁元件頁面的一個層麵包括將控制項或其他伺服器控制項新增 WebPart 至網頁元件頁面的能力。 控制項 CatalogZone 提供使用者可以新增至頁面的控制項清單或目錄。
控制項 CatalogZone 是 Web 元件控制項集中的其中一個基本控制項。 它衍生自 CatalogZoneBase 類別,而且大部分的行為都是繼承自該類別。 類別 CatalogZone 基本上會將區域範本新增至基類,這是 介面的實作 ITemplate 。 區域範本可讓開發人員以宣告方式將控制項新增 CatalogPart 至頁面持續性格式的區域。
重要
CatalogZone區域只能 CatalogPart 包含控制項,相反地, CatalogPart 控制項只能位於衍生自 類別的區域 CatalogZoneBase ,例如 CatalogZone 。
CatalogZone只有當使用者將網頁切換到目錄顯示模式時,控制項才會變成可見 (CatalogDisplayMode) 。 目錄可以包含數種類型的 CatalogPart 控制項。 每個 CatalogPart 控制項都是容器類型,其中包含使用者可以新增至頁面的伺服器控制項。 控制項 CatalogPart 會根據它們所包含的伺服器控制項來源而有所不同。 下表摘要說明 CatalogPart Web 元件控制項集所提供的控制項,以及針對每個控制項,其所包含的伺服器控制項種類。
控制 | 描述 |
---|---|
PageCatalogPart | 維護頁面上已關閉之控制項的參考。 這些控制項可以重新開啟, (由使用者新增回頁面) 。 |
DeclarativeCatalogPart | 包含網頁標記中 Web 元件目錄中宣告之控制項的參考。 使用者可以將這些控制項新增至網頁。 |
ImportCatalogPart | 提供 UI,讓使用者上傳定義檔, (具有 的 XML 檔案。WebPart 延伸模組和指定的格式,其中包含控制項至目錄的狀態資訊) ,以便將控制項新增至網頁。 |
因為 類別 CatalogZone 只會將區域範本新增至其基類的行為,所以它有幾個成員。 建 CatalogZone 構函式是無參數建 CatalogZone 構函式;透過此建構函式,您可以初始化 類別的新實例。 屬性 ZoneTemplate 會取得或設定包含區域控制項之 物件的參考 ITemplate 。 方法 CreateCatalogParts 很重要。 它會覆寫基底方法,以建立區域範本中包含的所有 CatalogPart 控制項集合。
注意
UI 中的 CatalogZone 按鈕需要用戶端腳本才能正常運作。 如果在瀏覽器中停用腳本,使用者將無法透過 CatalogZone UI 執行動作。
Accessibility
根據預設,此控制項轉譯的標記可能不符合協助工具標準,例如 Web 內容協助工具指導方針 1.0 (WCAG) 優先順序 1 指導方針。 如需此控制項協助工具支援的詳細資訊,請參閱 ASP.NET 控制項和協助工具。
給繼承者的注意事項
如果您想要更充分掌控目錄 UI 的轉譯和行為,您可以建立自訂 CatalogZone 類別。 如果您不需要為控制項的使用者提供宣告式新增 CatalogPart 控制項的能力,則可以直接從 CatalogZoneBase 類別繼承。 如果您想要以宣告方式新增控制項,簡單方法是繼承自 CatalogZone 類別,因為它提供基本區域範本。
如果您繼承自 CatalogZone 類別,您可以覆寫 CreateCatalogParts() 方法,並使用 方法將自訂 CatalogPart 控制項新增至 CatalogPartCollection ,如果您想要更以程式設計方式控制將自訂 CatalogPart 控制項新增至您的區域。
建構函式
CatalogZone() |
初始化 CatalogZone 類別的新執行個體。 |
屬性
AccessKey |
取得或設定便捷鍵 (Access Key),可讓您快速巡覽至 Web 伺服器控制項。 (繼承來源 WebControl) |
Adapter |
針對控制項取得瀏覽器的特定配置器。 (繼承來源 Control) |
AddVerb |
取得 WebPartVerb 物件的參考,這個物件可讓使用者從目錄加入控制項至 Web 組件頁面。 (繼承來源 CatalogZoneBase) |
AppRelativeTemplateSourceDirectory |
取得或設定包含了此控制項之 Page 或 UserControl 物件的相對應用程式虛擬目錄。 (繼承來源 Control) |
AssociatedDisplayModes |
取得與特定 WebPartDisplayMode 區域相關聯的 ToolZone 物件集合。 (繼承來源 ToolZone) |
Attributes |
取得任意屬性 (Attribute) 的集合 (只供呈現),不與控制項上的屬性 (Property) 對應。 (繼承來源 WebControl) |
BackColor |
取得或設定 Web 伺服器控制項的背景色彩。 (繼承來源 WebControl) |
BackImageUrl |
取得或設定區域背景影像的 URL。 (繼承來源 WebZone) |
BindingContainer |
取得包含了此控制項之資料繫結的控制項。 (繼承來源 Control) |
BorderColor |
取得或設定 Web 控制項的框線色彩。 (繼承來源 WebControl) |
BorderStyle |
取得或設定 Web 伺服器控制項的框線樣式。 (繼承來源 WebControl) |
BorderWidth |
取得或設定 Web 伺服器控制項的框線寬度。 (繼承來源 WebControl) |
CatalogPartChrome |
取得與 CatalogPartChrome 區域相關聯之 CatalogZoneBase 類別執行個體的參考。 (繼承來源 CatalogZoneBase) |
CatalogParts |
取得 CatalogPart 區域中包含之所有 CatalogZoneBase 控制項的集合。 (繼承來源 CatalogZoneBase) |
ChildControlsCreated |
取得值,指出是否已經建立伺服器控制項的子控制項。 (繼承來源 Control) |
ClientID |
取得 ASP.NET 所產生之 HTML 標記的控制項識別碼。 (繼承來源 Control) |
ClientIDMode |
取得或設定用來產生 ClientID 屬性值的演算法。 (繼承來源 Control) |
ClientIDSeparator |
取得字元值,表示在 ClientID 屬性中所使用的分隔字元。 (繼承來源 Control) |
CloseVerb |
取得 WebPartVerb 物件的參考,該物件可讓使用者關閉目錄使用者介面 (UI),並讓頁面返回標準瀏覽模式。 (繼承來源 CatalogZoneBase) |
Context |
取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。 (繼承來源 Control) |
Controls |
取得表示 ControlCollection 中之子控制項的 CompositeControl 物件。 (繼承來源 CompositeControl) |
ControlStyle |
取得 Web 伺服器控制項的樣式。 這個屬性主要由控制項開發人員使用。 (繼承來源 WebControl) |
ControlStyleCreated |
取得值,指出 Style 物件是否已經為 ControlStyle 屬性建立。 這個屬性主要由控制項開發人員使用。 (繼承來源 WebControl) |
CssClass |
取得或設定用戶端上 Web 伺服器控制項所呈現的階層式樣式表 (CSS)。 (繼承來源 WebControl) |
DataItemContainer |
如果命名容器實作 IDataItemContainer,則取得命名容器的參考。 (繼承來源 Control) |
DataKeysContainer |
如果命名容器實作 IDataKeysControl,則取得命名容器的參考。 (繼承來源 Control) |
DesignMode |
取得值,指出控制項是否正用於設計介面上。 (繼承來源 Control) |
Display |
取得值,其中該值指出目前是否顯示 ToolZone 控制項。 (繼承來源 ToolZone) |
EditUIStyle |
取得 ToolZone 控制項包含之控制項的樣式屬性。 (繼承來源 ToolZone) |
EmptyZoneText |
取得或設定區域不包含控制項時出現的訊息。 (繼承來源 CatalogZoneBase) |
EmptyZoneTextStyle |
取得空區域中替代符號文字的樣式屬性。 (繼承來源 WebZone) |
Enabled |
取得或設定值,指出 Web 伺服器控制項是否啟用。 (繼承來源 WebControl) |
EnableTheming |
取得或設定值,指出佈景主題是否套用至此控制項。 (繼承來源 WebControl) |
EnableViewState |
取得或設定值,該值表示伺服器控制項是否對要求的用戶端而言保持其檢視狀態,以及它包含的任何子控制項狀態。 (繼承來源 Control) |
ErrorStyle |
取得呈現錯誤訊息的樣式屬性,無法載入或建立 WebPart 控制項時會顯示該錯誤訊息。 (繼承來源 WebZone) |
Events |
取得控制項事件處理常式委派 (Delegate) 的清單。 這個屬性是唯讀的。 (繼承來源 Control) |
Font |
取得與 Web 伺服器控制項關聯的字型屬性。 (繼承來源 WebControl) |
FooterStyle |
取得區域頁尾區內容的樣式屬性。 (繼承來源 WebZone) |
ForeColor |
取得或設定 Web 伺服器控制項的前景色彩 (通常是文字的色彩)。 (繼承來源 WebControl) |
HasAttributes |
取得值,指出控制項是否已經設定屬性。 (繼承來源 WebControl) |
HasChildViewState |
取得值,指出目前伺服器控制項的子控制項是否有任何已儲存的檢視狀態設定。 (繼承來源 Control) |
HasFooter |
取得值,表示區域是否具有頁尾區。 (繼承來源 WebZone) |
HasHeader |
取得值,表示區域是否具有頁首區。 (繼承來源 WebZone) |
HeaderCloseVerb |
取得 WebPartVerb 控制項頁首中 ToolZone 物件的參考,該物件用於關閉控制項。 (繼承來源 ToolZone) |
HeaderStyle |
取得區域頁首區內容的樣式屬性。 (繼承來源 WebZone) |
HeaderText |
取得或設定區域的頁首區域文字。 (繼承來源 CatalogZoneBase) |
HeaderVerbStyle |
取得顯示於 ToolZone 控制項中所有頁首動詞命令的樣式屬性。 (繼承來源 ToolZone) |
Height |
取得或設定 Web 伺服器控制項的高度。 (繼承來源 WebControl) |
ID |
取得或設定指派給伺服器控制項的程式設計識別項。 (繼承來源 Control) |
IdSeparator |
取得用來分隔控制項識別項的字元。 (繼承來源 Control) |
InstructionText |
取得或設定為使用者提供指示之區域中的文字。 (繼承來源 CatalogZoneBase) |
InstructionTextStyle |
取得顯示在 ToolZone 控制項頂端之指示文字的樣式屬性。 (繼承來源 ToolZone) |
IsChildControlStateCleared |
取得值,指出這個控制項中所包含的控制項是否有控制項狀態。 (繼承來源 Control) |
IsEnabled |
取得值,指出是否啟用控制項。 (繼承來源 WebControl) |
IsTrackingViewState |
取得值,指出伺服器控制項是否正在儲存檢視狀態的變更。 (繼承來源 Control) |
IsViewStateEnabled |
取得值,指出這個控制項是否已啟用檢視狀態。 (繼承來源 Control) |
LabelStyle |
取得標籤內容的樣式屬性,該標籤顯示在 ToolZone 控制項中的編輯控制項旁。 衍生的 ToolZone 控制項 (例如 CatalogZone 和 EditorZone) 會將樣式套用至標籤。 (繼承來源 ToolZone) |
LoadViewStateByID |
取得值,指出控制項是否依 ID (而不是索引) 參與載入其檢視狀態。 (繼承來源 Control) |
NamingContainer |
取得伺服器控制項命名容器的參考,其建立唯一命名空間,在具有相同 ID 屬性值的伺服器控制項之間作區別。 (繼承來源 Control) |
Padding |
取得或設定表格的儲存格填補屬性,該表格包含區域的 WebPart 控制項。 (繼承來源 WebZone) |
Page |
取得含有伺服器控制項的 Page 執行個體的參考。 (繼承來源 Control) |
Parent |
在網頁控制階層架構中取得伺服器控制項之父控制項的參考。 (繼承來源 Control) |
PartChromePadding |
取得或設定 WebPart 控制項的內容與此控制項的框線之間的距離。 (繼承來源 WebZone) |
PartChromeStyle |
取得樣式特性,該樣式特性套用至區域中 Web 組件控制項的框線。 (繼承來源 WebZone) |
PartChromeType |
取得或設定區域中架構 Web 組件控制項的框線類型。 (繼承來源 WebZone) |
PartLinkStyle |
取得包含 CatalogPart 控制項之樣式屬性的物件,而這些控制項目前在區域中並未選取。 (繼承來源 CatalogZoneBase) |
PartStyle |
取得樣式特性,該樣式特性套用至區域中每個 Web 組件控制項的框線和內容。 (繼承來源 WebZone) |
PartTitleStyle |
取得區域中每個 Web 組件控制項標題列內容的樣式屬性。 (繼承來源 WebZone) |
RenderClientScript |
取得值,指出是否在 Web 組件頁面上呈現用戶端指令碼。 (繼承來源 WebZone) |
RenderingCompatibility |
取得值,這個值會指定將與呈現 HTML 相容的 ASP.NET 版本。 (繼承來源 Control) |
SelectedCatalogPartID |
取得或設定字串,做為目前在區域中所選取之 CatalogPart 控制項的識別項。 (繼承來源 CatalogZoneBase) |
SelectedPartLinkStyle |
取得包含 CatalogPart 控制項之樣式屬性的物件,而此控制項目前已在區域中選取。 (繼承來源 CatalogZoneBase) |
SelectTargetZoneText |
取得或設定目錄使用者介面 (UI) 中控制項旁的文字,此控制項允許使用者選擇要加入已選取控制項的區域。 (繼承來源 CatalogZoneBase) |
ShowCatalogIcons |
取得或設定值,指出目錄中的伺服器控制項是否在目錄中顯示關聯的圖示。 (繼承來源 CatalogZoneBase) |
Site |
當呈現在設計介面上時,取得裝載目前控制項之容器的資訊。 (繼承來源 Control) |
SkinID |
取得或設定要套用至控制項的面板。 (繼承來源 WebControl) |
Style |
取得文字屬性的集合,將呈現為 Web 伺服器控制項的外部標記上的樣式屬性。 (繼承來源 WebControl) |
SupportsDisabledAttribute |
取得值,這個值表示當控制項的 |
TabIndex |
取得或設定 Web 伺服器控制項的定位索引。 (繼承來源 WebControl) |
TagKey |
取得對應至這個 Web 伺服器控制項的 HtmlTextWriterTag 值。 這個屬性主要由控制項開發人員使用。 (繼承來源 WebZone) |
TagName |
取得控制項標記的名稱。 這個屬性主要由控制項開發人員使用。 (繼承來源 WebControl) |
TemplateControl |
取得或設定包含了此控制項之樣板的參考。 (繼承來源 Control) |
TemplateSourceDirectory |
取得包含目前伺服器控制項的 Page 或 UserControl 的虛擬目錄。 (繼承來源 Control) |
ToolTip |
取得或設定當滑鼠指標停留在 Web 伺服器控制項時顯示的文字。 (繼承來源 WebControl) |
UniqueID |
取得伺服器控制項唯一的、符合階層架構的識別項。 (繼承來源 Control) |
ValidateRequestMode |
取得或設定值,指出控制項是否對來自瀏覽器的用戶端輸入檢查潛在的危險值。 (繼承來源 Control) |
VerbButtonType |
取得或設定用於表示區域動詞命令的按鈕類型。 (繼承來源 WebZone) |
VerbStyle |
取得使用者介面 (UI) 動詞命令的樣式屬性,該動詞命令與區域中的 Web 組件控制項相關聯。 (繼承來源 WebZone) |
ViewState |
取得狀態資訊的字典,允許您在相同網頁的多個要求之間,儲存和還原伺服器控制項的檢視狀態。 (繼承來源 Control) |
ViewStateIgnoresCase |
取得值,指出 StateBag 物件是否不區分大小寫。 (繼承來源 Control) |
ViewStateMode |
取得或設定這個控制項的檢視狀態模式。 (繼承來源 Control) |
Visible |
取得或設定值,指出伺服器控制項是否要呈現為網頁上的使用者介面 (UI) 項目。 (繼承來源 ToolZone) |
WebPartManager |
取得 WebPartManager 控制項的參考,該控制項與 Web 組件頁面上的 WebZone 控制項執行個體相關聯。 (繼承來源 WebZone) |
Width |
取得或設定 Web 伺服器控制項的寬度。 (繼承來源 WebControl) |
ZoneTemplate |
取得或設定樣板,以頁面保存格式將子控制項包含在 CatalogZone 控制項之中。 |
方法
事件
DataBinding |
發生於伺服器控制項繫結至資料來源時。 (繼承來源 Control) |
Disposed |
發生於伺服器控制項從記憶體釋放時,這是在要求 ASP.NET 網頁時,伺服器控制項生命週期的最後階段。 (繼承來源 Control) |
Init |
發生於初始化伺服器控制項時,是其生命週期中的第一個步驟。 (繼承來源 Control) |
Load |
發生於載入伺服器控制項至 Page 物件時。 (繼承來源 Control) |
PreRender |
在 Control 物件載入之後但在呈現之前發生。 (繼承來源 Control) |
Unload |
發生於伺服器控制項從記憶體卸載時。 (繼承來源 Control) |
明確介面實作
擴充方法
FindDataSourceControl(Control) |
傳回與指定之控制項的資料控制項相關聯的資料來源。 |
FindFieldTemplate(Control, String) |
傳回在指定之控制項的命名容器中所指定資料行的欄位樣板。 |
FindMetaTable(Control) |
傳回包含資料控制項的中繼資料表物件。 |
GetDefaultValues(INamingContainer) |
取得所指定資料控制項的預設值集合。 |
GetMetaTable(INamingContainer) |
取得所指定資料控制項中的資料表中繼資料。 |
SetMetaTable(INamingContainer, MetaTable) |
設定所指定資料控制項中的資料表中繼資料。 |
SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>) |
設定所指定資料控制項的資料表中繼資料及預設值對應。 |
SetMetaTable(INamingContainer, MetaTable, Object) |
設定所指定資料控制項的資料表中繼資料及預設值對應。 |
TryGetMetaTable(INamingContainer, MetaTable) |
判斷資料表中繼資料是否可供使用。 |
EnableDynamicData(INamingContainer, Type) |
針對指定的資料控制項啟用動態資料行為。 |
EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>) |
針對指定的資料控制項啟用動態資料行為。 |
EnableDynamicData(INamingContainer, Type, Object) |
針對指定的資料控制項啟用動態資料行為。 |
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應