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

CatalogPart クラス

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

CatalogZoneBase ゾーン配置しユーザーWeb ページ追加できる Web サーバー コントロール (特に WebPart コントロール) のカタログ提供するコントロール基本クラスとして機能します

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

<BindableAttribute(False)> _
Public MustInherit Class
 CatalogPart
    Inherits Part
[BindableAttribute(false)] 
public abstract class CatalogPart : Part
[BindableAttribute(false)] 
public ref class CatalogPart abstract : public
 Part
/** @attribute BindableAttribute(false) */ 
public abstract class CatalogPart extends Part
BindableAttribute(false) 
public abstract class CatalogPart extends
 Part
解説解説

CatalogPart クラスは、CatalogZoneBase ゾーン配置される特殊なコントロール基本クラスです。これらの派生 CatalogPart コントロールには、エンド ユーザーWeb ページ追加できる Web サーバー コントロールカタログ用意されています。エンド ユーザーサーバー コントロール追加移動によって Web ページ機能柔軟に変更できるようにする場合は、Web アプリケーションCatalogPart コントロール使用します

カタログは、ユーザーWeb ページ追加できる 1 つ上の Web サーバー コントロール (WebPart コントロールASP.NET サーバー コントロールカスタム コントロールユーザー コントロールなど) のリストです。カタログには、エンド ユーザー向けの説明テキスト、各サーバー コントロール説明テキストサーバー コントロール選択してページ追加するためのヘルパー コントロール、共通ヘッダー、共通フッター、共通の境界線多数スタイル属性など、多数の共通スタイル特性格納されています。

次の表に示されるように、Web パーツ コントロール セット提供される 3 種類の CatalogPart コントロール存在しますそれぞれの種類CatalogPart コントロールには、さまざまなソースからページ追加されるサーバー コントロール含まれます。

メモ重要 :

CatalogPart クラスから継承されコントロールは、CatalogZoneBase クラスから派生したゾーンにしか配置できません。

CatalogPart クラスは、基本 Part クラスから継承されるため、Web パーツ コントロール セットの他のパーツ コントロールと共通の動作備えてます。また、このクラスは、カタログ機能に役立ついくつかのメンバ追加します。DisplayTitle プロパティは、現在コントロールタイトルとして表示されている実際文字列取得します。このプロパティの値は、Title プロパティの値か、またはそのプロパティに値が割り当てられていない場合には .NET Framework によって提供される既定値同じにできます。WebPartManager プロパティおよび Zone プロパティによって、CatalogPart コントロール有効期間制御する 2 つ基本的なオブジェクトである WebPartManager コントロールおよび CatalogPart コントロール含んだ CatalogZoneBase ゾーンそれぞれに簡単にアクセスできます

CatalogPart クラスには、いくつかのメソッド含まれています。GetAvailableWebPartDescriptions メソッドは、継承先によって実装される必要がある抽象メソッドとして宣言されます。このメソッドは、カタログ内のコントロール説明コレクション返します関連するメソッドである GetWebPart も抽象メソッドとして宣言され継承先によって実装される必要があります。このメソッドは、パラメータとしてメソッド渡される説明基づいてWebPart コントロールインスタンス返します

継承時の注意 CatalogPart クラス抽象型であるため、Web ページ上で直接使用できません。Web パーツ コントロール セットには、基本クラスから派生し Web パーツ ページ上で使用できる 3 つの CatalogPart コントロール用意されています。これらのコントロールについては、このトピックの「解説」の表を参照してください。これらのコントロールでは、Web サーバー コントロールカタログ作成するために必要となるほとんどの機能用意されています。ただし、特殊な要件がある場合には、カスタム CatalogPart コントロール開発必要になります。たとえば、Web サービス経由して、あるいは直接データベースからサーバー コントロール利用できるようにするための特殊な種類CatalogPart コントロール作成できますこのためには、CatalogPart クラスから継承する必要がありますまた、抽象 GetAvailableWebPartDescriptions メソッドおよび抽象 GetWebPart メソッドオーバーライドして、WebPart または他のサーバー コントロールとそれらの説明返す実装提供する必要もあります。さらに、各種サーバー コントロールデータベースWeb サービスから読み込むためのメソッド必要になります

使用例使用例

CatalogPart クラス使用方法を示すコード例次に示します。このクラス抽象型であるため、コードから直接使用できません。ただし、これとは別の例として、Web パーツ コントロール セット提供される 3 つの派生 CatalogPart コントロール一般的な使用方法次のコード例示します

このコード例4 つ部分構成されます。

コード例最初部分は、Web ページ上の表示モードユーザー変更できるようにするユーザー コントロールです。このコードは、(使用する言語に応じて) Displaymodemenuscs.ascx または Displaymodemenuvb.ascx という名前のファイル保存する必要があります表示モード詳細、およびこのコントロールソース コード説明については、「チュートリアル : 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="&nbsp;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="&nbsp;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 番目の部分Web ページです。このページには CatalogZone コントロール含まれ、子の <zonetemplate> 要素の中で、Web パーツ コントロール セットと共に提供される 3 つそれぞれの CatalogPart コントロール宣言されます。いくつかの属性DeclarativeCatalogPart コントロール設定されページの <script> セクションでも、そのコントロール属性プログラムによってアクセスされます。このコントロールには、ユーザーページ追加できるコントロールとして、標準Calendar コントロール1 つ含まれます。CatalogZone コントロールおよび CatalogPart コントロールは、ユーザーページカタログ表示モード切り替えたときにだけ表示されます。

このページには WebPartZone コントロール含まれており、その子<zonetemplate> 要素内には、XML ファイルからの交互に切り替わるメッセージ表示する AdRotator コントロールありますページ表示されているときに、ユーザー閉じ動詞クリックしてコントロール閉じた場合、そのコントロールページ カタログ追加されます。ユーザーは、ページカタログ表示モード切り替えPageCatalogPart コントロールアクセスして、閉じたコントロール追加して元に戻すことにより、コントロール再度開くことができます

<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  Protected Sub Button1_Click(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    Label1.Text = "<h3>DeclarativeCatalogPart Property Values</h3>"
 & _
      "Display Title: " & DeclarativeCatalogPart1.DisplayTitle
 & _
      "<br />" & _
      "Description: " & DeclarativeCatalogPart1.Description
 & _
      "<br />" & _
      "Chrome type: " & DeclarativeCatalogPart1.ChromeType.ToString()
    
  End Sub

  Protected Sub WebPartManager1_DisplayModeChanged(ByVal
 sender _
    As Object, ByVal e As
 WebPartDisplayModeEventArgs)
    Label1.Text = String.Empty
    If WebPartManager1.DisplayMode _
      Is WebPartManager.CatalogDisplayMode Then
      Button1.Visible = True
    Else
      Button1.Visible = False
    End If
  End Sub
</script>
<html  >
<head runat="server">
    <title>CatalogPart Samples</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="WebPartZone1" runat="server">
      <ZoneTemplate>
        <asp:AdRotator ID="AdRotator1" runat="server"
 
          AdType="Banner" 
          AdvertisementFile="~/quotes.xml" 
          Title="Favorite Quotes"  />         
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:CatalogZone ID="CatalogZone1" runat="server">
      <ZoneTemplate>
        <asp:DeclarativeCatalogPart 
          ID="DeclarativeCatalogPart1" 
          runat="server"
          Title="Controls to Add"
          ChromeType="TitleOnly"
          Description="Provides a list of controls that users
 can
            add to the page.">
          <WebPartsTemplate>
            <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:Button ID="Button1" runat="server"
 
      Text="Display DeclarativeCatalogPart Properties"
 
      OnClick="Button1_Click" 
      Visible="false"/>
    <br />
    <asp:Label ID="Label1" runat="server"
 Text="" />
  </form>
</body>
</html>
<%@ 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">

<script runat="server">
  
  protected void Button1_Click(object sender,
 EventArgs e)
  {
    
    Label1.Text = "<h3>DeclarativeCatalogPart Property Values</h3>"
 +
      "Display Title: " + DeclarativeCatalogPart1.DisplayTitle + 
      "<br />" + 
      "Description: " + DeclarativeCatalogPart1.Description + 
      "<br />" + 
      "Chrome type: " + DeclarativeCatalogPart1.ChromeType.ToString();
  }

  protected void WebPartManager1_DisplayModeChanged(object
 sender, 
    WebPartDisplayModeEventArgs e)
  {
    Label1.Text = String.Empty;
    if (WebPartManager1.DisplayMode == WebPartManager.CatalogDisplayMode)
      Button1.Visible = true;
    else
      Button1.Visible = false;
  }
</script>
<html  >
<head runat="server">
    <title>CatalogPart Samples</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="WebPartZone1" runat="server">
      <ZoneTemplate>
        <asp:AdRotator ID="AdRotator1" runat="server" 
          AdType="Banner" 
          AdvertisementFile="~/quotes.xml" 
          Title="Favorite Quotes"  />         
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:CatalogZone ID="CatalogZone1" runat="server">
      <ZoneTemplate>
        <asp:DeclarativeCatalogPart 
          ID="DeclarativeCatalogPart1" 
          runat="server"
          Title="Controls to Add"
          ChromeType="TitleOnly"
          Description="Provides a list of controls that users can
            add to the page.">
          <WebPartsTemplate>
            <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:Button ID="Button1" runat="server" 
      Text="Display DeclarativeCatalogPart Properties" 
      OnClick="Button1_Click" 
      Visible="false"/>
    <br />
    <asp:Label ID="Label1" runat="server" Text=""
 />
  </form>
</body>
</html>

コード例4 番目の部分XML ファイルです。このファイルは、ページ上で宣言される AdRotator コントロールソース ファイルです。このファイルには、コントロールによって定期的に入れ替えられて表示されるお気に入り引用文含まれています。次の内容テキスト エディタコピーし、Quotes.xml という名前で保存してください

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <AlternateText>
      A stitch in time saves nine.
    </AlternateText>    
  </Ad>
  <Ad>
    <AlternateText>
      A penny saved is a penny earned.
    </AlternateText>    
  </Ad>
</Advertisements>

コード例実行するには、Web ページブラウザ読み込みます。[表示モード] ドロップダウン コントロールで、[カタログ] を選択してページカタログ表示モード切り替えますCalendar コントロール含まれる DeclarativeCatalogPart コントロール設定され各種プロパティ値がどのように影響を及ぼすかに注意してくださいCalendar コントロールの横のチェック ボックスオンにし、[追加] をクリックするとそのコントロールページ追加できます。[Display DeclarativeCatalogPart Properties] ボタンクリックすると、そのコントロールプロパティの値が表示されます。[閉じる] をクリックしてページ通常のブラウズ モード戻しページ追加したコントロール表示できます。ここで、AdRotator コントロール動詞メニュー (タイトル バー下向き矢印表されます) に移動し、[閉じる] をクリックします。コントロール閉じられページ カタログ追加されます。ページカタログ表示モード再度切り替え、[ページ カタログ] ハイパーリンククリックしてPageCatalogPart コントロール表示しますAdRotator コントロールは、ここではそのタイトルである [Favorite Quotes] で参照されます。[Favorite Quotes] コントロール選択し、[追加] ボタンクリックしてコントロールページに再び追加します。[閉じる] ボタンクリックしてページブラウズ モード戻します

メモメモ

ImportCatalogPart コントロールはこのページでも宣言されていますが、コントロールインポートする方法を示すサンプルはより複雑になるため、このコード例ではコントロールの完全な使用方法示されていません。実際に動作する例については、ImportCatalogPart クラスまたは CatalogZone クラスクラス概要ドキュメント参照してください

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
       System.Web.UI.WebControls.Panel
         System.Web.UI.WebControls.WebParts.Part
          System.Web.UI.WebControls.WebParts.CatalogPart
             System.Web.UI.WebControls.WebParts.DeclarativeCatalogPart
             System.Web.UI.WebControls.WebParts.ImportCatalogPart
             System.Web.UI.WebControls.WebParts.PageCatalogPart
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「CatalogPart クラス」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS