CatalogZoneBase イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

関連項目
CatalogZoneBase クラスSystem.Web.UI.WebControls.WebParts 名前空間
CatalogPart クラス
その他の技術情報
ASP.NET Web パーツ ページCatalogZoneBase クラス
アセンブリ: System.Web (system.web.dll 内)


CatalogZoneBase クラスは、ToolZone クラスから継承する基本クラスで、ユーザーが Web ページに追加できるコントロールのリストまたはカタログを提供する、派生ゾーンの動作の基本セットを提供します。
CatalogZoneBase クラスは、一意のユーザー インターフェイス (UI) を提供します。エンド ユーザーは、この UI を使用して、WebPart コントロールおよび他のサーバー コントロール (ASP.NET サーバー コントロール、ユーザー コントロール、およびカスタム サーバー コントロールなど) を Web ページに追加できます。CatalogZone などの CatalogZoneBase クラスから派生するコントロールは、実際に Web ページに配置されるコントロールであり、CatalogPart コントロールと呼ばれるその他のコントロールのコンテナとして機能します。これらは、ユーザーがページに追加するサーバー コントロールのリストを作成します。CatalogZoneBase クラスから派生するゾーンは、ページがカタログ表示モードの場合だけに表示されます。
![]() |
---|
CatalogZoneBase ゾーンには、CatalogPart コントロールだけを含めることができます。逆にいうと、CatalogPart コントロールは、CatalogZoneBase ゾーンだけに存在できます。 |
サーバー コントロールへのカタログの追加には、基本 CatalogPart クラスから派生する 3 つのコントロールのセットが使用されます。3 つの CatalogPart コントロールを次の表に示します。
PageCatalogPart | ページで終了されたコントロールへの参照を保持します。ユーザーは、これらのコントロールを再度開く (ページに戻す) ことができます。 |
DeclarativeCatalogPart | Web ページのマークアップ内の Web パーツ カタログで宣言されているコントロールへの参照を含みます。これらのコントロールを、ユーザーが Web ページに追加できます。 |
ImportCatalogPart | コントロールを Web ページに追加できるように、ユーザーが定義ファイル (.WebPart 拡張子を持つ XML ファイル。コントロールの設定をインポートする) をカタログにアップロードするための UI を提供します。定義ファイルをインポートする前に、コントロールをサーバーに配置しておく必要があります。 |
CatalogZoneBase クラスには、WebPart コントロールのカタログを表示するのに便利なプロパティが多数あります。AddVerb プロパティは、カタログ内で選択したコントロールをページに追加する動詞を参照します。一方、CloseVerb プロパティは、カタログを閉じてページの表示モードをブラウズ モードに戻す動詞を参照します。CatalogParts プロパティは、ゾーン内のすべての CatalogPart コントロールのコレクションを参照します。EmptyZoneText、HeaderText、および InstructionText の各プロパティなどの複数のテキスト指向のプロパティは、基本プロパティをオーバーライドしてカタログに合った既定のテキストを提供します。SelectTargetZoneText プロパティは、ユーザーがコントロールの追加先のゾーンを選択できるドロップダウン リスト コントロールの横に表示されるテキストを含みます。
その他にも複数のプロパティが CatalogZoneBase クラスに含まれています。SelectedCatalogPartID プロパティは、現在選択されている CatalogPart コントロールの一意の文字列識別子です。ShowCatalogIcons プロパティは、WebPart コントロールの CatalogIconImageUrl プロパティを設定することによってコントロールに関連付けることができるアイコンを表示するかどうかを示します。
PartLinkStyle プロパティは、ゾーン内で現在選択されていない CatalogPart コントロールへのリンクのスタイル属性を含みます。これに対して、SelectedPartLinkStyle プロパティは、ゾーン内でユーザーが現在選択している CatalogPart コントロールへのリンクのスタイル属性を含みます。
これらのプロパティに加えて、CatalogZoneBase クラスには、他の基本コントロールから継承される標準のイベント処理メソッドおよびレンダリング メソッド以外に、特にコントロールのカタログを処理するためにデザインされているメソッドが複数あります。CreateCatalogPartChrome メソッドは、ゾーン内で各 CatalogPart コントロールを囲むクロム (境界線、動詞、アイコン、タイトルなどの周辺の UI 要素) を作成します。また、コントロールのレンダリングも処理します。CreateCatalogParts メソッドは、抽象メソッドであり、ゾーンに含まれるすべての CatalogPart コントロールのインスタンスを作成するように、派生クラスでオーバーライドされます。InvalidateCatalogParts メソッドは、ゾーン内の CatalogPart コントロールのコレクションが何らかのプログラム上の理由で変更される場合に、派生クラスによって呼び出すことができます。このとき、派生クラスはコレクションを再作成する必要があります。LoadPostData メソッドは、ページがサーバーにポスト バックされるたびに、カタログの WebPart コントロールの横のチェック ボックス用に、以前の既存の状態を読み込みます。逆に、SaveControlState メソッドは、チェック ボックスの状態を保存します。最後に、RenderCatalogPartLinks メソッドは、ゾーンに含まれる各 CatalogPart コントロールへのリンクのすべてのレンダリングを提供します。
継承時の注意 CatalogPart コントロールをホストするためにカスタム ゾーンを開発する場合は、ゾーン テンプレートのサポートを提供するかどうかを決定する必要があります。ゾーン テンプレートは、ITemplate インターフェイスを実装するタイプによって作成されます。また、カスタム ゾーンを使用するページ開発者が、Web ページの宣言マークアップでゾーン内の CatalogPart コントロールを参照できるようにする場合は、このゾーン テンプレートが必要です。ゾーン テンプレートのサポートが必要な場合は、CatalogZone クラスから継承する必要があります。これに対して、カスタム ゾーンとその CatalogPart コントロールを単体で使用できるようにする場合で、これらをプログラムで作成するときにゾーン テンプレートで宣言によってページ開発者がコントロールを指定するオプションを含めない場合は、CatalogZoneBase クラスから直接継承できます。CatalogZoneBase クラスから継承する場合は、CreateCatalogParts メソッドをオーバーライドし、カタログに含める WebPart またはその他のサーバー コントロールを CatalogPartCollection オブジェクトに追加する必要があります。
CatalogZoneBase クラスの宣言およびプログラムでの複数の使用を示すコード例を次に示します。これは抽象クラスのため、コード例では、Web パーツ コントロール セットに付属する派生 CatalogZone クラスを使用します。また、CatalogZoneBase クラスから継承するプロパティおよびメソッドをデモンストレーションします。
-
Web ページ上の表示モードを変更することのできるユーザー コントロール。
-
CatalogZone コントロールへの参照を含む Web ページ、および主要な CatalogZoneBase クラス メンバの一部の使用を示すコード。
コード例の最初の部分は、ページ上の表示モードを変更できるようにするユーザー コントロールです。表示モードの詳細、およびこのコントロールのソース コードの説明については、「チュートリアル : Web パーツ ページでの表示モードの変更」を参照してください。
<%@ 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" /> <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="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" /> <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>
コード例の 2 番目の部分は、CatalogZone コントロールへの宣言参照を含む Web ページです。ページの先頭近くに、2 つの Register ディレクティブがあります。1 つはユーザー コントロール用、もう 1 つはカスタム WebPart コントロール用です。<asp:WebPartZone> 要素の下には、カスタムの WebPart コントロールおよび ASP.NET Calendar コントロールへの宣言参照を含む <asp: CatalogZone> 要素があります。ゾーンには、その外観および動作を指定するために設定されるさまざまなタグおよびプロパティもあります。ページの <script> タグ間には、さまざまなイベント処理コードがあり、そのほとんどは、CatalogZoneBase メンバのプログラムによるさまざまな使用を示します。
<%@ page language="vb" %> <%@ register TagPrefix="uc1" TagName="DisplayModeMenuVB" Src="DisplayModeMenuvb.ascx" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="TextDisplayWebPartVB" %> <script runat="server"> Dim manager As WebPartManager Protected Sub WebPartManager1_DisplayModeChanged(ByVal sender _ As Object, ByVal e As WebPartDisplayModeEventArgs) If e.OldDisplayMode.Name <> "Catalog" Then Panel1.Visible = True Else Panel1.Visible = False End If End Sub Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) If CatalogZone1.AddVerb.Enabled Then CatalogZone1.AddVerb.Enabled = False CatalogZone1.CloseVerb.Enabled = False Else CatalogZone1.AddVerb.Enabled = True CatalogZone1.CloseVerb.Enabled = True End If End Sub Protected Sub Button2_Click(ByVal sender As Object, _ ByVal e As EventArgs) Label1.Text = "<h3>CatalogPart List</h3>" Dim part As CatalogPart For Each part In CatalogZone1.CatalogParts Label1.Text += part.ID + "<br />" Next part End Sub Protected Sub Button3_Click(ByVal sender As Object, _ ByVal e As EventArgs) CatalogZone1.SelectTargetZoneText = "Add to zone" CatalogZone1.EmptyZoneText = "Zone is empty" CatalogZone1.HeaderText = "My Updated Header" CatalogZone1.InstructionText = "My Updated Instructions" End Sub Protected Sub Button4_Click(ByVal sender As Object, _ ByVal e As EventArgs) Label1.Text = CatalogZone1.SelectedCatalogPartID End Sub Protected Sub Button5_Click(ByVal sender As Object, _ ByVal e As EventArgs) CatalogZone1.PartLinkStyle.ForeColor = _ System.Drawing.Color.Red CatalogZone1.SelectedPartLinkStyle.ForeColor = _ System.Drawing.Color.Blue End Sub </script> <html> <head id="Head1" runat="server"> <title> CatalogZoneBase Example </title> </head> <body> <form id="form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" OnDisplayModeChanged="WebPartManager1_DisplayModeChanged" /> <uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" /> <asp:webpartzone id="zone1" 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> </ZoneTemplate> </asp:webpartzone> <asp:CatalogZone ID="CatalogZone1" runat="server" EmptyZoneText="No controls are in the zone." HeaderText="My Web Parts Catalog" InstructionText="Add Web Parts controls to the zone." PartLinkStyle-Font-Italic="true" SelectedPartLinkStyle-Font-Bold="true" SelectTargetZoneText="Select zone" AddVerb-Text="Add Control" CloseVerb-Description="Close and return to browse mode." SelectedCatalogPartID="Currently Selected CatalogPart ID."> <ZoneTemplate> <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" runat="server"> <WebPartsTemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" ExportMode="All"/> <asp:Calendar id="calendar1" runat="server" title="My Calendar" /> </WebPartsTemplate> </asp:DeclarativeCatalogPart> <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" /> <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> </ZoneTemplate> </asp:CatalogZone> <hr /> <asp:CatalogZone ID="CatalogZone2" runat="server" BorderWidth="2" HeaderText="My Empty CatalogZone" EmptyZoneText="No controls are in the zone." /> <hr /> <asp:Panel ID="Panel1" runat="server" Visible="false"> <asp:Button ID="Button1" runat="server" Width="200" Text="Enable or Disable Verbs" OnClick="Button1_Click" /> <br /> <asp:Button ID="Button2" runat="server" Width="200" Text="List CatalogParts" OnClick="Button2_Click" /> <br /> <asp:Button ID="Button3" runat="server" Width="200" Text="Set Zone Text Properties" OnClick="Button3_Click" /> <br /> <asp:Button ID="Button4" runat="server" Width="200" Text="Show Selected CatalogPart ID" OnClick="Button4_Click" /> <br /> <asp:Button ID="Button5" runat="server" Width="200" Text="Change Part Link Styles" OnClick="Button5_Click" /> <br /> <asp:Label ID="Label1" runat="server" Text="" /></asp:Panel> </form> </body> </html>
<%@ page language="c#" %> <%@ register TagPrefix="uc1" TagName="DisplayModeMenuCS" Src="DisplayModeMenucs.ascx" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="TextDisplayWebPartCS" %> <script runat="server"> WebPartManager manager; protected void WebPartManager1_DisplayModeChanged(object sender, WebPartDisplayModeEventArgs e) { if (e.OldDisplayMode.Name != "Catalog") Panel1.Visible = true; else Panel1.Visible = false; } protected void Button1_Click(object sender, EventArgs e) { if (CatalogZone1.AddVerb.Enabled) { CatalogZone1.AddVerb.Enabled = false; CatalogZone1.CloseVerb.Enabled = false; } else { CatalogZone1.AddVerb.Enabled = true; CatalogZone1.CloseVerb.Enabled = true; } } protected void Button2_Click(object sender, EventArgs e) { Label1.Text = "<h3>CatalogPart List</h3>"; foreach(CatalogPart part in CatalogZone1.CatalogParts) { Label1.Text += part.ID + "<br />"; } } protected void Button3_Click(object sender, EventArgs e) { CatalogZone1.SelectTargetZoneText = "Add to zone"; CatalogZone1.EmptyZoneText = "Zone is empty"; CatalogZone1.HeaderText = "My Updated Header"; CatalogZone1.InstructionText = "My Updated Instructions"; } protected void Button4_Click(object sender, EventArgs e) { Label1.Text = CatalogZone1.SelectedCatalogPartID; } protected void Button5_Click(object sender, EventArgs e) { CatalogZone1.PartLinkStyle.ForeColor = System.Drawing.Color.Red; CatalogZone1.SelectedPartLinkStyle.ForeColor = System.Drawing.Color.Blue; } </script> <html> <head id="Head1" runat="server"> <title> CatalogZoneBase Example </title> </head> <body> <form id="form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" OnDisplayModeChanged="WebPartManager1_DisplayModeChanged" /> <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" /> <asp:webpartzone id="zone1" 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> </ZoneTemplate> </asp:webpartzone> <asp:CatalogZone ID="CatalogZone1" runat="server" EmptyZoneText="No controls are in the zone." HeaderText="My Web Parts Catalog" InstructionText="Add Web Parts controls to the zone." PartLinkStyle-Font-Italic="true" SelectedPartLinkStyle-Font-Bold="true" SelectTargetZoneText="Select zone" AddVerb-Text="Add Control" CloseVerb-Description="Close and return to browse mode." SelectedCatalogPartID="Currently Selected CatalogPart ID."> <ZoneTemplate> <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" runat="server"> <WebPartsTemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" ExportMode="All"/> <asp:Calendar id="calendar1" runat="server" title="My Calendar" /> </WebPartsTemplate> </asp:DeclarativeCatalogPart> <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" /> <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> </ZoneTemplate> </asp:CatalogZone> <hr /> <asp:CatalogZone ID="CatalogZone2" runat="server" BorderWidth="2" HeaderText="My Empty CatalogZone" EmptyZoneText="No controls are in the zone." /> <hr /> <asp:Panel ID="Panel1" runat="server" Visible="false"> <asp:Button ID="Button1" runat="server" Width="200" Text="Enable or Disable Verbs" OnClick="Button1_Click" /> <br /> <asp:Button ID="Button2" runat="server" Width="200" Text="List CatalogParts" OnClick="Button2_Click" /> <br /> <asp:Button ID="Button3" runat="server" Width="200" Text="Set Zone Text Properties" OnClick="Button3_Click" /> <br /> <asp:Button ID="Button4" runat="server" Width="200" Text="Show Selected CatalogPart ID" OnClick="Button4_Click" /> <br /> <asp:Button ID="Button5" runat="server" Width="200" Text="Change Part Link Styles" OnClick="Button5_Click" /> <br /> <asp:Label ID="Label1" runat="server" Text="" /></asp:Panel> </form> </body> </html>
コード例の 3 番目の部分は、TextDisplayWebPart という名前のカスタム WebPart コントロールです。これは、ゾーン内で宣言されており、エンド ユーザーはそれをカタログからページに追加できます。コード例を実行するためには、このソース コードをコンパイルする必要があります。それを明示的にコンパイルし、コンパイル済みのアセンブリを Web サイトの Bin フォルダまたはグローバル アセンブリ キャッシュに配置できます。サイトの App_Code フォルダにソース コードを配置し、実行時に動的にコンパイルすることもできます。両方のコンパイル方法の例については、「チュートリアル : カスタム サーバー コントロールの開発と使用」を参照してください。
Imports System 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 <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
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 { [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 (input.Text != String.Empty) { _contentText = input.Text + @"<br />"; input.Text = String.Empty; DisplayContent.Text = this.ContentText; } } } }
コード例を正常に処理するには、Web.config ファイルに追加しなければならない設定があります。これで Web パーツの記述ファイルのエクスポートを有効にします。このコード例の Web ページと同じディレクトリに Web.config ファイルがあることを確認します。<system.web> セクション内に、次のマークアップのように enableExport 属性が true に設定された <webParts> 要素があることを確認します。
<webParts enableExport="true">
...
</webParts>
ブラウザでページを読み込む場合、ドロップダウン リスト ボックスの [カタログ] を選択して、カタログ表示モードに切り替えることができます。カタログが表示されると、カタログからページに追加できる 2 つのサーバー コントロールが表示されます。また、CatalogZoneBase クラス メンバの宣言およびプログラムによる使用の効果も UI で確認できます。


System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.CompositeControl
System.Web.UI.WebControls.WebParts.WebZone
System.Web.UI.WebControls.WebParts.ToolZone
System.Web.UI.WebControls.WebParts.CatalogZoneBase
System.Web.UI.WebControls.WebParts.CatalogZone


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CatalogZoneBase コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタは、Web パーツ コントロール セットで提供される CatalogZone クラスなどの派生クラスが初期化されるときに呼び出されます。基本 CatalogZoneBase コンストラクタは、適切な WebPartDisplayMode オブジェクトを WebPartManager コントロールに渡すことによって、ページが Web パーツ カタログ ユーザー インターフェイス (UI) を表示する準備をします。特に、コンストラクタは、CatalogDisplayMode オブジェクトを渡します。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CatalogZoneBase プロパティ



関連項目
CatalogZoneBase クラスSystem.Web.UI.WebControls.WebParts 名前空間
CatalogPart クラス
その他の技術情報
ASP.NET Web パーツ ページCatalogZoneBase メソッド



名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackDataHandler.LoadPostData | CatalogZoneBase クラスの LoadPostData メソッドを呼び出すことにより、IPostBackDataHandler.LoadPostData メソッドを実装します。 |
![]() | System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent | このメンバの説明については、「RaisePostDataChangedEvent」を参照してください。 |

関連項目
CatalogZoneBase クラスSystem.Web.UI.WebControls.WebParts 名前空間
CatalogPart クラス
その他の技術情報
ASP.NET Web パーツ ページCatalogZoneBase メンバ
Web ページに追加できる WebPart コントロールのリストを含むカタログとして機能する、すべてのゾーン コントロールの基本クラスとして機能します。
CatalogZoneBase データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackDataHandler.LoadPostData | CatalogZoneBase クラスの LoadPostData メソッドを呼び出すことにより、IPostBackDataHandler.LoadPostData メソッドを実装します。 |
![]() | System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent | このメンバの説明については、「RaisePostDataChangedEvent」を参照してください。 |

関連項目
CatalogZoneBase クラスSystem.Web.UI.WebControls.WebParts 名前空間
CatalogPart クラス
その他の技術情報
ASP.NET Web パーツ ページ- CatalogZoneBaseのページへのリンク