CatalogPartCollection クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CatalogPartCollection クラスの意味・解説 

CatalogPartCollection クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

エンド ユーザーWeb ページ追加できる Web サーバー コントロールカタログ提供する CatalogPart コントロールコレクション格納します。このクラス継承できません。

名前空間: System.Web.UI.WebControls.WebParts
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 CatalogPartCollection
    Inherits ReadOnlyCollectionBase
Dim instance As CatalogPartCollection
public sealed class CatalogPartCollection :
 ReadOnlyCollectionBase
public ref class CatalogPartCollection sealed
 : public ReadOnlyCollectionBase
public final class CatalogPartCollection extends
 ReadOnlyCollectionBase
public final class CatalogPartCollection extends
 ReadOnlyCollectionBase
解説解説
使用例使用例

CatalogPartCollection クラス使用するいくつかの方法次のコード例示します。このコード例は、4 つ部分から構成されます。

コード例最初部分は、ユーザー コントロールです。ユーザー コントロールソース コードは、別のトピックのものを使用してます。このコード例実行するには、チュートリアル : Web パーツ ページでの表示モード変更トピック記載されているユーザー コントロール.ascx ファイルを、このコード例示されている .ascx ページと同じフォルダ配置する必要があります

コード例2 番目の部分TextDisplayWebPart コントロールです。コード例実行するためには、このソース コードコンパイルする必要があります。それを明示的にコンパイルし、コンパイル済みアセンブリWeb サイトBin フォルダまたはグローバル アセンブリ キャッシュ配置できますサイトの App_Code フォルダソース コード配置し実行時動的にコンパイルすることもできます両方コンパイル方法を示すチュートリアルについては、「チュートリアル : カスタム サーバー コントロール開発と使用」を参照してください。このコントロールは、ContentText という名前のプロパティ持ってます。このプロパティは、ユーザーテキスト ボックス入力した値を保持します

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;
      }
    }

  }
}

コード例3 番目の部分Web ページです。このページ<asp:catalogzone> 要素は、2 つCatalogPart コントロール宣言含んでます。これらのコントロールは、Button1_Click メソッド実行時作成されるカスタム CatalogPartCollection オブジェクト一部なります。PageCatalogPart コントロールは、以前実行時ユーザーによって閉じられWeb サーバー コントロール含んでます。PageCatalogPart コントロール内のコントロールは、再びページ追加できます。DeclarativeCatalogPart コントロールは、カスタム TextDisplayWebPart コントロール宣言含んでます。ページカタログ モードになっている場合ユーザーは、通常のブラウズ モード使用できるよう、TextDisplayWebPart コントロールページ追加できます

<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ Register TagPrefix="aspSample"
  Namespace="Samples.AspNet.VB.Controls"
 
  Assembly="TextDisplayWebPartVB"
 %> 

<script runat="server">
Protected Sub Button1_Click(ByVal
 sender As Object, ByVal
 e As EventArgs) 
    Dim list As New ArrayList(2)
    list.Add(PageCatalogPart1)
    list.Add(DeclarativeCatalogPart1)
    ' Pass an ICollection object to the constructor.
    Dim myParts As New CatalogPartCollection(list)
    Dim catalog As CatalogPart
    For Each catalog In
  myParts
        catalog.Description = "My " + catalog.DisplayTitle
    Next catalog
    
    ' Use the IndexOf property to locate a CatalogPart control.
    Dim PageCatalogPartIndex As Integer
 = _
      myParts.IndexOf(PageCatalogPart1)
    myParts(PageCatalogPartIndex).ChromeType = PartChromeType.TitleOnly
    
    ' Use the Contains method to see if a CatalogPart control exists.
    If myParts.Contains(PageCatalogPart1) Then
        Dim closedWebPart As WebPart = Nothing
        Dim descriptions As WebPartDescriptionCollection
 = _
          PageCatalogPart1.GetAvailableWebPartDescriptions()
        If descriptions.Count > 0 Then
            closedWebPart = PageCatalogPart1.GetWebPart(descriptions(0))
            closedWebPart.AllowClose = False
        End If
    End If
    
    ' Use indexers to display the details of the CatalogPart controls.
    Label1.Text = String.Empty
    Label1.Text = _
      "<h3>PageCatalogPart Details</h3>"
 & _
      "ID: " & myParts(0).ID + "<br
 />" & _
      "Count: " & myParts(0).GetAvailableWebPartDescriptions().Count
    Label1.Text += _
      "<h3>DeclarativeCatalogPart Details</h3>"
 & _
      "ID: " & myParts("DeclarativeCatalogPart1").ID
 & "<br />" & _
      "Count: " & myParts("DeclarativeCatalogPart1")
 _
        .GetAvailableWebPartDescriptions().Count

End Sub 
</script>  
<html  >
<head id="Head1" runat="server">
</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>
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:CatalogZone ID="CatalogZone1" runat="server">
      <ZoneTemplate>
        <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1"
 runat="server">
          <WebPartsTemplate>
            <aspSample:TextDisplayWebPart runat="server"
 
              id="TextDisplayWebPart1"
              Title="Text Display WebPart" />
          </WebPartsTemplate>
        </asp:DeclarativeCatalogPart>
        <asp:PageCatalogPart ID="PageCatalogPart1"
 runat="server" />  
      </ZoneTemplate>
    </asp:CatalogZone>
    <hr />
    <asp:Button ID="Button1" 
      runat="server" 
      Text="Display CatalogPart Properties" 
      OnClick="Button1_Click"/>
    <br />
    <asp:Label ID="Label1" runat="server"
 Text="" /> 
  </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">
  protected void Button1_Click(object sender,
 EventArgs e)
  {
    ArrayList list = new ArrayList(2);
    list.Add(PageCatalogPart1);
    list.Add(DeclarativeCatalogPart1);
    // Pass an ICollection object to the constructor.
    CatalogPartCollection myParts = new CatalogPartCollection(list);
    foreach (CatalogPart catalog in myParts)
    {
      catalog.Description = "My " + catalog.DisplayTitle;
    }

    // Use the IndexOf property to locate a CatalogPart control.
    int PageCatalogPartIndex = myParts.IndexOf(PageCatalogPart1);
    myParts[PageCatalogPartIndex].ChromeType = PartChromeType.TitleOnly;

    // Use the Contains method to see if a CatalogPart control exists.
    if (myParts.Contains(PageCatalogPart1))
    {
      WebPart closedWebPart = null;
      WebPartDescriptionCollection descriptions = PageCatalogPart1.GetAvailableWebPartDescriptions();
      if (descriptions.Count > 0)
      {
        closedWebPart = PageCatalogPart1.GetWebPart(descriptions[0]);
        closedWebPart.AllowClose = false;
      }
    }
    
    // Use indexers to display the details of the CatalogPart controls.
    Label1.Text = String.Empty;
    Label1.Text =
      "<h3>PageCatalogPart Details</h3>" +
      "ID: " + myParts[0].ID + "<br />" +
      "Count: " + myParts[0].GetAvailableWebPartDescriptions().Count;
    Label1.Text += 
      "<h3>DeclarativeCatalogPart Details</h3>" +
      "ID: " + myParts["DeclarativeCatalogPart1"].ID + "<br
 />" +
      "Count: " + myParts["DeclarativeCatalogPart1"].GetAvailableWebPartDescriptions().Count;
  }
</script> 
 
<html  >
<head id="Head1" runat="server">
</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>
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:CatalogZone ID="CatalogZone1" runat="server">
      <ZoneTemplate>
        <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" runat="server">
          <WebPartsTemplate>
            <aspSample:TextDisplayWebPart runat="server" 
              id="TextDisplayWebPart1"
              Title="Text Display WebPart" />
          </WebPartsTemplate>
        </asp:DeclarativeCatalogPart>
        <asp:PageCatalogPart ID="PageCatalogPart1" runat="server"
 />  
      </ZoneTemplate>
    </asp:CatalogZone>
    <hr />
    <asp:Button ID="Button1" 
      runat="server" 
      Text="Display CatalogPart Properties" 
      OnClick="Button1_Click"/>
    <br />
    <asp:Label ID="Label1" runat="server" Text=""
 /> 
  </form>
</body>
</html>

ブラウザページ読み込む場合、[Display Mode] ドロップダウン リスト コントロールで [カタログ] を選択することにより、ページカタログ モード切り替えることができますカスタム WebPart コントロールの横のチェック ボックスオンにし、 [追加] をクリックするとそのコントロールページ追加できます。[閉じる] をクリックしてページブラウズ モード戻します追加したコントロールで、動詞メニュー (タイトル バー表示される下向き矢印) をクリックして [閉じる] をクリックすると、そのコントロールページから削除されPageCatalogPart コントロール追加されます。ページカタログ モード戻し、[ページ カタログ] リンクをクリックして PageCatalogPart コントロール内容表示します閉じられコントロール表示されます。[Display CatalogPart Properties] ボタンクリックすると、CatalogPartCollection オブジェクトアクセスます。さらに、格納されている CatalogPart コントロール特定のプロパティ表示されます。

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Collections.ReadOnlyCollectionBase
    System.Web.UI.WebControls.WebParts.CatalogPartCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CatalogPartCollection メンバ
System.Web.UI.WebControls.WebParts 名前空間
CatalogPart クラス
その他の技術情報
ASP.NET Web パーツ ページ


このページでは「.NET Framework クラス ライブラリ リファレンス」からCatalogPartCollection クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCatalogPartCollection クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCatalogPartCollection クラスを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CatalogPartCollection クラス」の関連用語

CatalogPartCollection クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CatalogPartCollection クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS