ImportCatalogPart クラス

定義

あらかじめ定義した設定でコントロールを Web ページに追加できるように、WebPart コントロール (または WebPart コントロールとして使用される他の ASP.NET サーバー コントロール) の記述ファイルをインポートします。 このクラスは継承できません。

public ref class ImportCatalogPart sealed : System::Web::UI::WebControls::WebParts::CatalogPart
public sealed class ImportCatalogPart : System.Web.UI.WebControls.WebParts.CatalogPart
type ImportCatalogPart = class
    inherit CatalogPart
Public NotInheritable Class ImportCatalogPart
Inherits CatalogPart
継承

次のコード例では、Web ページでコントロールを ImportCatalogPart 宣言的およびプログラム的に使用する方法を示します。 この例には、次の 4 つの部分があります。

  • Web パーツ ページの表示モードを変更できるユーザー コントロール。

  • コントロールとImportCatalogPartコントロールをCatalogZone含む Web ページ。

  • 2 つのカスタム WebPart コントロールを含むソース コード ファイル。

  • ブラウザーでページを読み込む場合の例の動作の説明。

このコード例の最初の部分は、ユーザーが Web ページの表示モードを変更できるようにするユーザー コントロールです。 次のソース コードをファイルに配置し、Displaymodemenucs.ascx または Displaymodemenuvb.ascx という名前を付ける必要があります (使用している言語によって異なります)。 表示モードの詳細と、このコントロールのソース コードの説明については、「 チュートリアル: Web パーツ ページでの表示モードの変更」を参照してください。

<%@ 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" 
      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="&nbsp;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>

コード例の 2 番目の部分は Web ページです。 ページの上部には、ユーザー コントロール用と 2 つの register カスタム WebPart コントロールを含むコンパイル済みコンポーネント用の 2 つのディレクティブがあります。 ページには、宣言型要素の適切な階層内に ImportCatalogPart 入れ子になったコントロールへの宣言参照があることに注意してください。 また、いくつかのプロパティ値が 要素に宣言的に <asp:importcatalogpart> 割り当てられていることにも注意してください。 また、 メソッドは Button1_Click コントロールのプロパティ値の数を ImportCatalogPart 更新します。

ページの WebPartZone コントロールでは、2 つのカスタム WebPart コントロールが宣言されます。 コントロールには <aspSample:userinfowebpart>exportmode="all" 属性があります。 この属性は、ユーザーがコントロールの説明ファイルをエクスポートできるようにするために必要です。その後、説明ファイルを使用してコントロールをインポートする他のユーザーがインポートできます。

注意

Web パーツ アプリケーションのユーザーがコントロールの説明ファイルをエクスポートできるようにするには、Web.config ファイルWebPart内の 要素 (要素の<system.web>子) に<webParts>属性を追加enableExport="true"することで、Web アプリケーションのエクスポート機能も有効にする必要があります。 エクスポートは既定で無効になっているため、アプリケーションのエクスポートをまだ有効にしていない場合は、Web.config ファイルを編集して、今すぐ実行します。

<%@ 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">

<script runat="server">

  // <snippet3>
  protected void Button1_Click(object sender, EventArgs e)
  {
    ImportCatalogPart1.Title = "Import Server Controls";
    ImportCatalogPart1.BrowseHelpText = "Enter the path to a "
      + "description file.";
    ImportCatalogPart1.UploadButtonText = "Upload Description";
    ImportCatalogPart1.UploadHelpText = "Upload a description file.";
    ImportCatalogPart1.ImportedPartLabelText = "Imported Controls";
    ImportCatalogPart1.PartImportErrorLabelText = "An error occurred " 
      + "during the import process.";

  }
  // </snippet3>
  
  protected void Page_Load(object sender, EventArgs e)
  {
    Button1.Visible = false;
  }

  protected void ImportCatalogPart1_PreRender(object sender, 
    EventArgs e)
  {
    Button1.Visible = true;
  }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>
      ImportCatalogPart Control
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server"  />
      <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" />
      <asp:webpartzone id="zone1" runat="server" >
        <PartTitleStyle BorderWidth="1" 
          Font-Names="Verdana, Arial"
          Font-Size="110%"
          BackColor="LightBlue" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="TextDisplayWebPart1" 
            title = "Text Display WebPart" /> 
          <aspsample:userinfowebpart id="userinfo1" runat="server" 
            Title="User Information" exportmode="all" />
        </zonetemplate>
      </asp:webpartzone> 
      <asp:EditorZone ID="EditorZone1" runat="server">
        <ZoneTemplate>
          <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
            runat="server" />
        </ZoneTemplate>
      </asp:EditorZone>
      <asp:CatalogZone ID="CatalogZone1" runat="server">
        <ZoneTemplate>
          <asp:ImportCatalogPart ID="ImportCatalogPart1" 
            runat="server" 
            Title="My ImportCatalogPart" 
            OnPreRender="ImportCatalogPart1_PreRender"
            BrowseHelpText="Type a path or browse to find a control's 
              description file." 
            UploadButtonText="Upload Description File" 
            UploadHelpText="Click the button to upload the description 
              file."
            ImportedPartLabelText="My User Information WebPart" 
            PartImportErrorLabelText="An error occurred while trying 
              to import a description file."  />
        </ZoneTemplate>
      </asp:CatalogZone>
      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="Update ImportCatalogPart" 
        OnClick="Button1_Click" />
    </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">

<script runat="server">

  ' <snippet3>
  Protected Sub Button1_Click(ByVal sender As Object, _
    ByVal e As EventArgs)
      ImportCatalogPart1.Title = "Import Server Controls"
      ImportCatalogPart1.BrowseHelpText = "Enter the path to a " _
        & "description file."
      ImportCatalogPart1.UploadButtonText = "Upload Description"
      ImportCatalogPart1.UploadHelpText = "Upload a description file."
      ImportCatalogPart1.ImportedPartLabelText = "Imported Controls"
      ImportCatalogPart1.PartImportErrorLabelText = "An error occurred " _
        & "during the import process."
  End Sub
  ' </snippet3>

  Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As EventArgs)
      Button1.Visible = false
  End Sub

  Protected Sub ImportCatalogPart1_PreRender(ByVal sender As Object, _
    ByVal e As EventArgs)
      Button1.Visible = true
  End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      ImportCatalogPart Control
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server"  />
      <uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" />
      <asp:webpartzone id="zone1" runat="server" >
        <PartTitleStyle BorderWidth="1" 
          Font-Names="Verdana, Arial"
          Font-Size="110%"
          BackColor="LightBlue" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="TextDisplayWebPart1" 
            title = "Text Display WebPart" /> 
          <aspsample:userinfowebpart id="userinfo1" runat="server" 
            Title="User Information" exportmode="all" />
        </zonetemplate>
      </asp:webpartzone> 
      <asp:EditorZone ID="EditorZone1" runat="server">
        <ZoneTemplate>
          <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
            runat="server" />
        </ZoneTemplate>
      </asp:EditorZone>
      <asp:CatalogZone ID="CatalogZone1" runat="server">
        <ZoneTemplate>
          <asp:ImportCatalogPart ID="ImportCatalogPart1" 
            runat="server" 
            Title="My ImportCatalogPart" 
            OnPreRender="ImportCatalogPart1_PreRender"
            BrowseHelpText="Type a path or browse to find a control's 
              description file." 
            UploadButtonText="Upload Description File" 
            UploadHelpText="Click the button to upload the description 
              file."
            ImportedPartLabelText="My User Information WebPart" 
            PartImportErrorLabelText="An error occurred while trying 
              to import a description file."  />
        </ZoneTemplate>
      </asp:CatalogZone>
      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="Update ImportCatalogPart" 
        OnClick="Button1_Click" />
    </form>
  </body>
</html>

コード例の 3 番目の部分は、2 つの WebPart コントロールのソース コードです。 これらのコントロールの一部のプロパティは、 属性でマークされていることに WebBrowsable 注意してください。 これにより、コントロールが PropertyGridEditorPart 編集モードのときに、ユーザーがこれらのプロパティを編集するためのユーザー インターフェイス (UI) を動的に生成できます。 プロパティは属性で WebDisplayName マークされ、編集 UI の各コントロールの横に表示されるラベルのテキストを指定します。 コード例を実行するには、このソース コードをコンパイルする必要があります。 明示的にコンパイルし、結果のアセンブリを Web サイトの Bin フォルダーまたはグローバル アセンブリ キャッシュに配置できます。 または、ソース コードをサイトの App_Code フォルダーに配置して、実行時に動的にコンパイルすることもできます。 このコード例では、動的コンパイルを使用します。 両方のコンパイル方法を示すチュートリアルについては、「 チュートリアル: カスタム Web サーバー コントロールの開発と使用」を参照してください。

という TextDisplayWebPart カスタム コントロールは、 要素を使用して Web ページで <aspSample:TextDisplayWebPart> 参照されます。 と呼ばれる UserInfoWebPartもう 1 つのコントロールは、最初は 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
{
  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class UserInfoWebPart : WebPart
  {
    HttpServerUtility server = HttpContext.Current.Server;
    private String _userNickName = "Add a nickname.";
    private String _userPetName = "Add a pet name.";
    private DateTime _userSpecialDate = DateTime.Now;
    private Boolean _userIsCurrent = true;
    private JobTypeName _userJobType = JobTypeName.Unselected;
    public enum JobTypeName
    {
      Unselected = 0,
      Support = 1,
      Service = 2,
      Professional = 3, 
      Technical = 4,
      Manager = 5,
      Executive = 6
    }
    Label NickNameLabel;
    Label PetNickNameLabel;
    Label SpecialDateLabel;
    CheckBox IsCurrentCheckBox;
    Label JobTypeLabel;

    // Add the Personalizable and WebBrowsable attributes to the  
    // public properties, so that users can save property values  
    // and edit them with a PropertyGridEditorPart control.
    [Personalizable(), WebBrowsable, WebDisplayName("Nickname")]
    public String NickName
    {
      get 
      { 
        object o = ViewState["NickName"];
        if (o != null)
          return (string)o;
        else
          return _userNickName;        
      } 

      set { _userNickName = server.HtmlEncode(value); }
    }

    [Personalizable(), WebBrowsable, WebDisplayName("Pet Name")]
    public String PetName
    {
      get 
      { 
        object o = ViewState["PetName"];
        if (o != null)
          return (string)o;
        else
          return _userPetName;        
      }

      set { _userPetName = server.HtmlEncode(value); }
    }

    [Personalizable(), WebBrowsable(), WebDisplayName("Special Day")]
    public DateTime SpecialDay
    {
      get
      {
        object o = ViewState["SpecialDay"];
        if (o != null)
          return (DateTime)o;
        else
          return _userSpecialDate;
      }

      set { _userSpecialDate = value; }
    }

    [Personalizable(), WebBrowsable(), WebDisplayName("Job Type")]
    public JobTypeName UserJobType
    {
      get
      {
        object o = ViewState["UserJobType"];
        if (o != null)
          return (JobTypeName)o;
        else
          return _userJobType;
      }

      set { _userJobType = (JobTypeName)value; }
    }

    [Personalizable(), WebBrowsable(), WebDisplayName("Is Current")]
    public Boolean IsCurrent
    {
      get
      {
        object o = ViewState["IsCurrent"];
        if (o != null)
          return (Boolean)o;
        else
          return _userIsCurrent;
      }

      set { _userIsCurrent = value; }
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();

      NickNameLabel = new Label();
      NickNameLabel.Text = this.NickName;
      SetControlAttributes(NickNameLabel);

      PetNickNameLabel = new Label();
      PetNickNameLabel.Text = this.PetName;
      SetControlAttributes(PetNickNameLabel);

      SpecialDateLabel = new Label();
      SpecialDateLabel.Text = this.SpecialDay.ToShortDateString();
      SetControlAttributes(SpecialDateLabel);

      IsCurrentCheckBox = new CheckBox();
      IsCurrentCheckBox.Checked = this.IsCurrent;
      SetControlAttributes(IsCurrentCheckBox);

      JobTypeLabel = new Label();
      JobTypeLabel.Text = this.UserJobType.ToString();
      SetControlAttributes(JobTypeLabel);

      ChildControlsCreated = true;
    }

    private void SetControlAttributes(WebControl ctl)
    {
      ctl.BackColor = Color.White;
      ctl.BorderWidth = 1;
      ctl.Width = 200;
      this.Controls.Add(ctl);
    }

    protected override void RenderContents(HtmlTextWriter writer)
    {
      writer.Write("Nickname:");
      writer.WriteBreak();
      NickNameLabel.RenderControl(writer);
      writer.WriteBreak();
      writer.Write("Pet Name:");
      writer.WriteBreak();
      PetNickNameLabel.RenderControl(writer);
      writer.WriteBreak();
      writer.Write("Special Date:");
      writer.WriteBreak();
      SpecialDateLabel.RenderControl(writer);
      writer.WriteBreak();
      writer.Write("Job Type:");
      writer.WriteBreak();
      JobTypeLabel.RenderControl(writer);
      writer.WriteBreak();
      writer.Write("Current:");
      writer.WriteBreak();
      IsCurrentCheckBox.RenderControl(writer);
    }
  }

  [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 = Context.Server.HtmlEncode(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

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class UserInfoWebPart
    Inherits WebPart
    Private server As HttpServerUtility = HttpContext.Current.Server
    Private _userNickName As String = "Add a nickname."
    Private _userPetName As String = "Add a pet name."
    Private _userSpecialDate As DateTime = DateTime.Now
    Private _userIsCurrent As [Boolean] = True
    Private _userJobType As JobTypeName = JobTypeName.Unselected

    Public Enum JobTypeName
      Unselected = 0
      Support = 1
      Service = 2
      Professional = 3
      Technical = 4
      Manager = 5
      Executive = 6
    End Enum

    Private NickNameLabel As Label
    Private PetNickNameLabel As Label
    Private SpecialDateLabel As Label
    Private IsCurrentCheckBox As CheckBox
    Private JobTypeLabel As Label

    ' Add the Personalizable and WebBrowsable attributes to the  
    ' public properties, so that users can save property values  
    ' and edit them with a PropertyGridEditorPart control.

    <Personalizable(), WebBrowsable(), WebDisplayName("Nickname")> _
    Public Property NickName() As String
      Get
        Dim o As Object = ViewState("NickName")
        If Not (o Is Nothing) Then
          Return CStr(o)
        Else
          Return _userNickName
        End If
      End Get
      Set(ByVal value As String)
        _userNickName = server.HtmlEncode(value)
      End Set
    End Property

    <Personalizable(), WebBrowsable(), WebDisplayName("Pet Name")> _
    Public Property PetName() As String
      Get
        Dim o As Object = ViewState("PetName")
        If Not (o Is Nothing) Then
          Return CStr(o)
        Else
          Return _userPetName
        End If
      End Get
      Set(ByVal value As String)
        _userPetName = server.HtmlEncode(value)
      End Set
    End Property

    <Personalizable(), WebBrowsable(), WebDisplayName("Special Day")> _
    Public Property SpecialDay() As DateTime
      Get
        Dim o As Object = ViewState("SpecialDay")
        If Not (o Is Nothing) Then
          Return CType(o, DateTime)
        Else
          Return _userSpecialDate
        End If
      End Get

      Set(ByVal value As DateTime)
        _userSpecialDate = value
      End Set
    End Property

    <Personalizable(), WebBrowsable(), WebDisplayName("Job Type")> _
    Public Property UserJobType() As JobTypeName
      Get
        Dim o As Object = ViewState("UserJobType")
        If Not (o Is Nothing) Then
          Return CType(o, JobTypeName)
        Else
          Return _userJobType
        End If
      End Get
      Set(ByVal value As JobTypeName)
        _userJobType = CType(value, JobTypeName)
      End Set
    End Property

    <Personalizable(), WebBrowsable(), WebDisplayName("Is Current")> _
    Public Property IsCurrent() As [Boolean]
      Get
        Dim o As Object = ViewState("IsCurrent")
        If Not (o Is Nothing) Then
          Return CType(o, [Boolean])
        Else
          Return _userIsCurrent
        End If
      End Get
      Set(ByVal value As [Boolean])
        _userIsCurrent = value
      End Set
    End Property

    Protected Overrides Sub CreateChildControls()
      Controls.Clear()

      NickNameLabel = New Label()
      NickNameLabel.Text = Me.NickName
      SetControlAttributes(NickNameLabel)

      PetNickNameLabel = New Label()
      PetNickNameLabel.Text = Me.PetName
      SetControlAttributes(PetNickNameLabel)

      SpecialDateLabel = New Label()
      SpecialDateLabel.Text = Me.SpecialDay.ToShortDateString()
      SetControlAttributes(SpecialDateLabel)

      IsCurrentCheckBox = New CheckBox()
      IsCurrentCheckBox.Checked = Me.IsCurrent
      SetControlAttributes(IsCurrentCheckBox)

      JobTypeLabel = New Label()
      JobTypeLabel.Text = Me.UserJobType.ToString()
      SetControlAttributes(JobTypeLabel)

      ChildControlsCreated = True

    End Sub

    Private Sub SetControlAttributes(ByVal ctl As WebControl)
      ctl.BackColor = Color.White
      ctl.BorderWidth = 1
      ctl.Width = 200
      Me.Controls.Add(ctl)
    End Sub

    Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
      writer.Write("Nickname:")
      writer.WriteBreak()
      NickNameLabel.RenderControl(writer)
      writer.WriteBreak()
      writer.Write("Pet Name:")
      writer.WriteBreak()
      PetNickNameLabel.RenderControl(writer)
      writer.WriteBreak()
      writer.Write("Special Date:")
      writer.WriteBreak()
      SpecialDateLabel.RenderControl(writer)
      writer.WriteBreak()
      writer.Write("Job Type:")
      writer.WriteBreak()
      JobTypeLabel.RenderControl(writer)
      writer.WriteBreak()
      writer.Write("Current:")
      writer.WriteBreak()
      IsCurrentCheckBox.RenderControl(writer)

    End Sub

  End Class


  <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 String.IsNullOrEmpty(input.Text) = False Then
        _contentText = Context.Server.HtmlEncode(input.Text) + "<br />"
        input.Text = String.Empty
        DisplayContent.Text = Me.ContentText
      End If

    End Sub

  End Class

End Namespace

次に、コード例を実行します。 ブラウザーに Web ページを読み込みます。 最初の手順では、コントロールを編集します UserInfoWebPart[表示モード] ドロップダウン リスト コントロールを使用し、[編集] を選択してページを編集モードに切り替えます。 コントロールの動詞メニュー UserInfoWebPart (タイトル バーの下向き矢印) をクリックし、[ 編集] をクリックします。 編集 UI が表示されると、いくつかの編集コントロールがコントロールの下に UserInfoWebPart 表示され、フィールド値の編集に使用できます。 一部のフィールドを編集し、[ OK] をクリックし、[ 表示モード ] ドロップダウンを使用してページを参照モードに戻します。

2 番目の手順では、 をエクスポートします。コントロールの UserInfoWebPart WebPart 記述ファイル。 (タイトル バーの下向き矢印で表される) カスタム コントロールの動詞メニューをクリックし、[ エクスポート] をクリックします。 指示に従って を保存します。コントロールの WebPart 記述ファイル。 次に、Web ページを閉じ、エディターでページ ソースを編集します。 コントロール宣言要素を <aspSample:userinfowebpart> 削除し、ファイルを保存して閉じます。 (この手順を実行して、コントロールをまだ持っていないユーザーを UserInfoWebPart シミュレートするため、コントロールをページにインポートできます)。

ブラウザーで Web ページをもう一度読み込みます。 UserInfoWebPart削除したため、コントロールは表示されません。 [表示モード] ドロップダウン リスト コントロールを使用し、[カタログ] を選択してページをカタログ モードに切り替えます。 コントロールで、[ImportCatalogPart参照] ボタンをクリックし、 を参照します。作成した WebPart ファイルをクリックし、[アップロード] ボタンをクリックします。 コントロールへの参照が、その横にチェック ボックスと共に表示されます。 [チェック] ボックスを選択し、[追加] をクリックしてコントロールをページに追加します。

ページのこのビューでは、ページの下部付近にある [ImportCatalogPart の更新 ] ボタンをクリックして、プログラムによってコントロールに対して多数のプロパティ値を更新する効果を ImportCatalogPart 確認します。 ボタンをクリックした後、UI のさまざまなプロパティがどのように変更されるかを確認します。

最後に、[ 閉じる ] をクリックしてカタログ モードを終了し、ページを参照モードに戻します。 コントロールが UserInfoWebPart ページに表示され、前にエクスポートしたときに持っていた値が含まれます。

注釈

コントロールを使用すると、ユーザーが ImportCatalogPart ゾーンに追加するコントロールまたはサーバー コントロールの WebPart 設定を記述する説明ファイルを WebPartZoneBase インポートできます。

ユーザーが説明ファイルをインポートすると、 WebPart ファイル内で参照されているコントロールがコントロール内に ImportCatalogPart 表示され、ユーザーはコントロールをページに追加できます。

説明ファイルは、コントロール自体と同じではありません。 これは、 で終わる XML ファイルです。WebPart 拡張機能と には、コントロールの状態を表す名前と値のペア (主にプロパティ値) が含まれます。 説明ファイルは、「 Web パーツ コントロール記述ファイル」のトピックで説明されているように、指定された XML 形式に従って作成されます。

説明ファイルが参照するコントロールについては、アセンブリにコンパイルすることも、.ascx ファイルで定義されたユーザー コントロールにすることもできます。 どちらの場合も、インポートされた説明ファイルで参照されるコントロールは、コントロールのインポートを試みるページをホストする Web サーバー上に存在する必要があります。 説明ファイルは、コントロール名と、コントロールを含むアセンブリ (またはファイル) を参照し、説明ファイルにはコントロールのプロパティ値、外観、および動作に影響する設定が含まれています。

コントロールを使用すると、ユーザーは ImportCatalogPart コントロールの設定を共有できます。 複雑なコントロールには、多くのプロパティと設定を含めることができます。 たとえば、大企業内の一般的なイントラネット サイトでは、カスタム WebPart コントロールには、ユーザーの環境に固有の値 (データベース接続、部門情報など) を保持するプロパティが多数含まれている場合があります。 コントロールには、その外観に影響を与える多数のプロパティが含まれている場合もあります。 あるユーザーは、特定のサイトでコントロールをカスタマイズして適切に動作させ、コントロールの説明ファイルをエクスポートしてから、その説明ファイルを他のユーザーと共有し、そのファイルをインポートして、カスタマイズが許可されている他のイントラネット サイトに完全に構成されたコントロールを追加できます。 コントロールを含むコンパイル済みアセンブリまたはユーザー コントロール ファイルが、サイトをホストしている Web サーバー上に存在する限り、ユーザーはコントロールを他の Web サイトに追加できます。

ユーザーが説明ファイル (および関連するサーバー コントロール) を Web ページにインポートするメカニズムは、ページ開発者が ImportCatalogPart Web ページに追加する必要があるコントロールです。 ユーザーがページをカタログ表示モードに切り替えると、コントロールが ImportCatalogPart 表示され、ユーザーはこのコントロールを使用して を参照できます。インポートするサーバー コントロールに対応する WebPart 記述ファイル。 コントロールによって ImportCatalogPart 提供される UI と指示に従って、ユーザーは Web ページに目的のサーバー コントロールを追加できます。その外観とプロパティは、インポートされた説明ファイルで指定されたとおりに完全に構成されます。

コントロールの説明ファイルを WebPart インポートする前に、ユーザーはまず、既存 WebPart のコントロールに基づいてファイルを作成 (エクスポート) する必要があります。 次の条件が満たされている場合は、コントロールの説明ファイルをエクスポートできます。

  • コントロールには、 属性でマークされたプロパティがあります Personalizable

  • Web.config ファイルには、 要素の enableExport 属性値が に true 設定されています <webParts>

  • 開発者は、コントロールの プロパティの ExportMode 値を、 の既定値以外の None値に設定します。これにより、エクスポートが禁止されます。 プロパティ値が ExportModeNonSensitiveData設定されている場合、ユーザーが説明ファイルをエクスポートするときに、属性を IsSensitive 持つ Personalizable パラメーターを含むプロパティはエクスポートされません。 これにより、コントロール開発者は、接続文字列などの機密データが特定の状況でエクスポートされるのを防ぐことができます。

ユーザーは、コントロールの動詞メニューに表示されるエクスポート動詞をクリックし、指示に従って を保存することで、エクスポートが有効になっているコントロールをエクスポートできます。コントロールの WebPart 記述ファイル。 その後、他のユーザーはこのファイルをインポートして、コントロールの独自のインスタンスを構成できます。

クラスには ImportCatalogPart 、いくつかのプロパティが含まれています。 BrowseHelpTextプロパティには、ユーザーが参照して説明ファイルを見つける際の手順を含むテキストが含まれています。 ImportedPartLabelTextプロパティには、コントロール内に表示されるインポートされたコントロールのラベルとして機能するテキストがImportCatalogPart含まれています。 PartImportErrorLabelTextには、コントロールの説明をインポートするときにエラーが発生した場合に表示されるテキストが含まれます。 プロパティは Title 、基本プロパティをオーバーライドして、開発者がタイトル ImportCatalogPart を割り当てない場合にコントロールの既定のタイトルを割り当てます。 プロパティには UploadButtonText 、ユーザーが説明ファイルをアップロードするためにクリックしたボタンのテキストが含まれており UploadHelpText 、プロパティにはアップロード プロセスの手順が含まれています。

ImportCatalogPartクラスには、いくつかの一意のメソッドも含まれています。 メソッドはGetAvailableWebPartDescriptions、カタログ内の各WebPartコントロールのオブジェクトを取得WebPartDescriptionします。これにより、コントロールは、そのインスタンスを作成しなくても、各サーバー コントロールに関する情報を表示できますImportCatalogPart。 メソッドは GetWebPart 、 メソッドに渡された説明に基づいて、特定 WebPart のコントロールのインスタンスを取得します。

コントロールの使用 ImportCatalogPart には固有のリスクがいくつかあります。 1 つの例として、インポートに使用される説明ファイルを使用して、悪意のあるデータを Web アプリケーションにインポートする可能性があります。 悪意のあるスクリプト コードを説明ファイルの文字列プロパティの値として配置した場合、ユーザーが説明ファイルをインポートし、参照先サーバー コントロールを Web ページに追加したときに、そのスクリプトが実行される可能性があります。 悪意のあるデータを含む説明ファイルをインポートするリスクを最小限に抑えるために、文字列型のプロパティを持つサーバー コントロールは常にプロパティ データをエンコードする必要があります。 もう 1 つのリスクには、説明ファイルを使用した型のインポートが含まれます ( 「Web パーツ コントロールの説明ファイル」を参照してください)。 悪意のあるユーザーが に多数のアセンブリ AppDomainを読み込む要求を送信すると、過剰な量のメモリが消費される可能性があります。

インポートに関連するリスクを回避するには、インポート機能またはコントロールを使用しないことで、機能を完全に ImportCatalogPart 無効にすることができます。 または、コントロールにアクセスできるユーザーを制限することもできます。 これは、ロール管理を使用してプログラムで行うことができます (「 ロールを使用した承認の管理」を参照してください)。 たとえば、ページが読み込まれるときに、ユーザーが管理者ロールなどの特定のロールに属しているかどうかをテストして確認できます。 ユーザーがロールに含まれている場合は、プログラムによってそのユーザーの ImportCatalogPart ページにコントロールを追加できます。 宣言型のアプローチを使用して、コントロールを使用できるユーザーのセットを ImportCatalogPart 制限することもできます。 カタログを含む Web ページ内には、インポートできるユーザー用とできないユーザー用の 2 つの CatalogZone コントロールを配置できます。 インポートできるユーザーのゾーンには、 コントロールが ImportCatalogPart 含まれます。 ゾーン自体をコントロールの内部に LoginView 配置できます。これにより、ゾーン内のコントロールの使用を、指定した認証されたユーザーまたはロールのみに制限できます。

コンストラクター

ImportCatalogPart()

ImportCatalogPart クラスの新しいインスタンスを初期化します。

プロパティ

AccessKey

Web サーバー コントロールにすばやく移動できるアクセス キーを取得または設定します。

(継承元 WebControl)
Adapter

コントロール用のブラウザー固有のアダプターを取得します。

(継承元 Control)
AppRelativeTemplateSourceDirectory

このコントロールが含まれている Page オブジェクトまたは UserControl オブジェクトのアプリケーション相対の仮想ディレクトリを取得または設定します。

(継承元 Control)
Attributes

コントロールのプロパティに対応しない任意の属性 (表示専用) のコレクションを取得します。

(継承元 WebControl)
BackColor

Web サーバー コントロールの背景色を取得または設定します。

(継承元 WebControl)
BackImageUrl

パネル コントロールの背景イメージの URL を取得または設定します。

(継承元 Panel)
BindingContainer

このコントロールのデータ バインディングを格納しているコントロールを取得します。

(継承元 Control)
BorderColor

Web コントロールの境界線の色を取得または設定します。

(継承元 WebControl)
BorderStyle

Web サーバー コントロールの境界線スタイルを取得または設定します。

(継承元 WebControl)
BorderWidth

Web サーバー コントロールの境界線の幅を取得または設定します。

(継承元 WebControl)
BrowseHelpText

ユーザーに、記述ファイルの場所を参照するように指示するテキスト メッセージを取得または設定します。

ChildControlsCreated

サーバー コントロールの子コントロールが作成されたかどうかを示す値を取得します。

(継承元 Control)
ChromeState

パーツ コントロールが最小化または標準のどちらの状態で表示されるかを示す値を取得または設定します。

(継承元 Part)
ChromeType

Web パーツ コントロールを囲む境界線の種類を取得または設定します。

(継承元 Part)
ClientID

ASP.NET によって生成される HTML マークアップのコントロール ID を取得します。

(継承元 Control)
ClientIDMode

ClientID プロパティの値を生成するために使用されるアルゴリズムを取得または設定します。

(継承元 Control)
ClientIDSeparator

ClientID プロパティで使用される区切り記号を表す文字値を取得します。

(継承元 Control)
Context

現在の Web 要求に対するサーバー コントロールに関連付けられている HttpContext オブジェクトを取得します。

(継承元 Control)
Controls

ユーザー インターフェイスの階層構造の指定されたサーバー コントロールの子コントロールを格納している ControlCollection オブジェクトを取得します。

(継承元 Part)
ControlStyle

Web サーバー コントロールのスタイルを取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
ControlStyleCreated

Style オブジェクトが ControlStyle プロパティに対して作成されたかどうかを示す値を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
CssClass

クライアントで Web サーバー コントロールによって表示されるカスケード スタイル シート (CSS: Cascading Style Sheet) クラスを取得または設定します。

(継承元 WebControl)
DataItemContainer

名前付けコンテナーが IDataItemContainer を実装している場合、名前付けコンテナーへの参照を取得します。

(継承元 Control)
DataKeysContainer

名前付けコンテナーが IDataKeysControl を実装している場合、名前付けコンテナーへの参照を取得します。

(継承元 Control)
DefaultButton

ユーザー インターフェイス (UI) で、ボタンを含むフォームがレンダリングされるときにフォーカスを得る既定のボタンとして扱うボタンを取得または設定します。 このプロパティは、ページ開発者コードから呼び出すためのものではありません。

Description

パーツ コントロールのツールヒントやカタログで使用する、パーツ コントロールの動作をまとめた短い語句を取得または設定します。

(継承元 Part)
DesignMode

コントロールがデザイン サーフェイスで使用されているかどうかを示す値を取得します。

(継承元 Control)
Direction

テキストを含むコントロールを Panel コントロールに表示する方向を取得または設定します。

(継承元 Panel)
DisplayTitle

CatalogPart コントロールの現在の実際のタイトルを含む文字列を取得します。

(継承元 CatalogPart)
Enabled

Web サーバー コントロールを有効にするかどうかを示す値を取得または設定します。

(継承元 WebControl)
EnableTheming

テーマがこのコントロールに適用されるかどうかを示す値を取得または設定します。

(継承元 WebControl)
EnableViewState

要求元クライアントに対して、サーバー コントロールがそのビュー状態と、そこに含まれる任意の子のコントロールのビュー状態を保持するかどうかを示す値を取得または設定します。

(継承元 Control)
Events

コントロールのイベント ハンドラー デリゲートのリストを取得します。 このプロパティは読み取り専用です。

(継承元 Control)
Font

Web サーバー コントロールに関連付けられたフォント プロパティを取得します。

(継承元 WebControl)
ForeColor

Web サーバー コントロールの前景色 (通常はテキストの色) を取得または設定します。

(継承元 WebControl)
GroupingText

パネル コントロールに格納されているコントロールのグループのキャプションを取得または設定します。

(継承元 Panel)
HasAttributes

コントロールに属性セットがあるかどうかを示す値を取得します。

(継承元 WebControl)
HasChildViewState

現在のサーバー コントロールの子コントロールが、保存されたビューステートの設定を持っているかどうかを示す値を取得します。

(継承元 Control)
Height

Web サーバー コントロールの高さを取得または設定します。

(継承元 WebControl)
HorizontalAlign

パネルの内容の水平方向の配置を取得または設定します。

(継承元 Panel)
ID

サーバー コントロールに割り当てられたプログラム ID を取得または設定します。

(継承元 Control)
IdSeparator

コントロール ID を区別するために使用する文字を取得します。

(継承元 Control)
ImportedPartLabelText

ユーザーが記述ファイルをインポートした後に表示されるテキストを取得または設定します。これは、インポートされたコントロールのカタログ内で個別のインポート済みコントロールを表現または説明するためのテキストです。

IsChildControlStateCleared

このコントロールに含まれているコントロールに、コントロールの状態が設定されているかどうかを示す値を取得します。

(継承元 Control)
IsEnabled

コントロールが有効かどうかを示す値を取得します。

(継承元 WebControl)
IsTrackingViewState

サーバー コントロールがビューステートの変更を保存しているかどうかを示す値を取得します。

(継承元 Control)
IsViewStateEnabled

このコントロールでビューステートが有効かどうかを示す値を取得します。

(継承元 Control)
LoadViewStateByID

コントロールがインデックスではなく ID によりビューステートの読み込みを行うかどうかを示す値を取得します。

(継承元 Control)
NamingContainer

同じ ID プロパティ値を持つ複数のサーバー コントロールを区別するための一意の名前空間を作成する、サーバー コントロールの名前付けコンテナーへの参照を取得します。

(継承元 Control)
Page

サーバー コントロールを含んでいる Page インスタンスへの参照を取得します。

(継承元 Control)
Parent

ページ コントロールの階層構造における、サーバー コントロールの親コントロールへの参照を取得します。

(継承元 Control)
PartImportErrorLabelText

インポート プロセスでエラーが発生した場合に表示されるエラー メッセージを取得または設定します。

RenderingCompatibility

レンダリングされる HTML と互換性がある ASP.NET のバージョンを表す値を取得します。

(継承元 Control)
ScrollBars

Panel コントロールのスクロール バーの表示状態と位置を取得または設定します。

(継承元 Panel)
Site

デザイン サーフェイスに現在のコントロールを表示するときに、このコントロールをホストするコンテナーに関する情報を取得します。

(継承元 Control)
SkinID

コントロールに適用するスキンを取得または設定します。

(継承元 WebControl)
Style

Web サーバー コントロールの外側のタグにスタイル属性として表示されるテキスト属性のコレクションを取得します。

(継承元 WebControl)
SupportsDisabledAttribute

コントロールの disabled プロパティが IsEnabled の場合、レンダリングされた HTML 要素の false 属性を "無効" に設定するかどうかを示す値を取得します。

(継承元 Panel)
TabIndex

Web サーバー コントロールのタブ インデックスを取得または設定します。

(継承元 WebControl)
TagKey

この Web サーバー コントロールに対応する HtmlTextWriterTag 値を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
TagName

コントロール タグの名前を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
TemplateControl

このコントロールを格納しているテンプレートへの参照を取得または設定します。

(継承元 Control)
TemplateSourceDirectory

現在のサーバー コントロールを格納している Page または UserControl の仮想ディレクトリを取得します。

(継承元 Control)
Title

ImportCatalogPart コントロールのタイトル バーに表示されるタイトルを取得または設定します。

ToolTip

マウス ポインターが Web サーバー コントロールの上を移動したときに表示されるテキストを取得または設定します。

(継承元 WebControl)
UniqueID

階層構造で修飾されたサーバー コントロールの一意の ID を取得します。

(継承元 Control)
UploadButtonText

記述ファイルのアップロードを開始する Button コントロールのテキストを取得または設定します。

UploadHelpText

ユーザーに記述ファイルをアップロードする方法を通知するメッセージのテキストを取得または設定します。

ValidateRequestMode

ブラウザーからのクライアント入力の安全性をコントロールで調べるかどうかを示す値を取得または設定します。

(継承元 Control)
ViewState

同一のページに対する複数の要求にわたって、サーバー コントロールのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。

(継承元 Control)
ViewStateIgnoresCase

StateBag オブジェクトが大文字小文字を区別しないかどうかを示す値を取得します。

(継承元 Control)
ViewStateMode

このコントロールのビューステート モードを取得または設定します。

(継承元 Control)
Visible

サーバー コントロールがページ上の UI としてレンダリングされているかどうかを示す値を取得または設定します。

(継承元 Control)
WebPartManager

WebPartManager クラスの現在のインスタンスへの参照を取得します。

(継承元 CatalogPart)
Width

Web サーバー コントロールの幅を取得または設定します。

(継承元 WebControl)
Wrap

パネルの内容をラップするかどうかを示す値を取得または設定します。

(継承元 Panel)
Zone

CatalogZoneBase コントロールを含んでいる CatalogPart ゾーンへの参照を取得します。

(継承元 CatalogPart)

メソッド

AddAttributesToRender(HtmlTextWriter)

背景イメージ、配置、ラップ、および表示する属性のリストの方向に関する情報を追加します。

(継承元 Panel)
AddedControl(Control, Int32)

子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。

(継承元 Control)
AddParsedSubObject(Object)

XML または HTML のいずれかの要素が解析されたことをサーバー コントロールに通知し、サーバー コントロールの ControlCollection オブジェクトに要素を追加します。

(継承元 Control)
ApplyStyle(Style)

指定したスタイルの空白以外の要素を Web コントロールにコピーして、コントロールの既存のスタイル要素を上書きします。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
ApplyStyleSheetSkin(Page)

ページのスタイル シートに定義されたスタイル プロパティをコントロールに適用します。

(継承元 Control)
BeginRenderTracing(TextWriter, Object)

レンダリング データのデザイン時のトレースを開始します。

(継承元 Control)
BuildProfileTree(String, Boolean)

ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。

(継承元 Control)
ClearCachedClientID()

キャッシュされた ClientID 値を null に設定します。

(継承元 Control)
ClearChildControlState()

サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。

(継承元 Control)
ClearChildState()

サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。

(継承元 Control)
ClearChildViewState()

サーバー コントロールのすべての子コントロールのビューステート情報を削除します。

(継承元 Control)
ClearEffectiveClientIDMode()

現在のコントロール インスタンスおよびすべての子コントロールの ClientIDMode プロパティを Inherit に設定します。

(継承元 Control)
CopyBaseAttributes(WebControl)

指定した Web サーバー コントロールから、Style オブジェクトでカプセル化されていないプロパティをこのメソッドの呼び出し元の Web サーバー コントロールにコピーします。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
CreateChildControls()

ASP.NET ページ フレームワークによって呼び出され、ポストバックまたはレンダリングの準備として、合成ベースの実装を使うサーバー コントロールに対し、それらのコントロールに含まれる子コントロールを作成するように通知します。

(継承元 Control)
CreateControlCollection()

サーバー コントロールの子コントロール (リテラルとサーバーの両方) を保持する新しい ControlCollection オブジェクトを作成します。

(継承元 Control)
CreateControlStyle()

すべてのスタイル関連プロパティを実装するために Panel コントロールが内部で使用するスタイル オブジェクトを作成します。

(継承元 Panel)
DataBind()

呼び出されたサーバー コントロールとそのすべての子コントロールにデータ ソースをバインドします。

(継承元 Part)
DataBind(Boolean)

DataBinding イベントを発生させるオプションを指定して、呼び出されたサーバー コントロールとそのすべての子コントロールにデータ ソースをバインドします。

(継承元 Control)
DataBindChildren()

データ ソースをサーバー コントロールの子コントロールにバインドします。

(継承元 Control)
Dispose()

サーバー コントロールが、メモリから解放される前に最終的なクリーンアップを実行できるようにします。

(継承元 Control)
EndRenderTracing(TextWriter, Object)

レンダリング データのデザイン時のトレースを終了します。

(継承元 Control)
EnsureChildControls()

サーバー コントロールに子コントロールが含まれているかどうかを確認します。 含まれていない場合、子コントロールを作成します。

(継承元 Control)
EnsureID()

ID が割り当てられていないコントロールの ID を作成します。

(継承元 Control)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
FindControl(String)

指定した id パラメーターを使用して、サーバー コントロールの現在の名前付けコンテナーを検索します。

(継承元 Control)
FindControl(String, Int32)

指定した id および検索に役立つ pathOffset パラメーターに指定された整数を使用して、サーバー コントロールの現在の名前付けコンテナーを検索します。 この形式の FindControl メソッドはオーバーライドしないでください。

(継承元 Control)
Focus()

コントロールに入力フォーカスを設定します。

(継承元 Control)
GetAvailableWebPartDescriptions()

カタログ内で利用できる WebPart コントロールの説明のコレクションを返します。

GetDesignModeState()

CatalogPart コントロールの親ゾーンの現在の状態を取得します。

(継承元 CatalogPart)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetRouteUrl(Object)

ルート パラメーターのセットに対応する URL を取得します。

(継承元 Control)
GetRouteUrl(RouteValueDictionary)

ルート パラメーターのセットに対応する URL を取得します。

(継承元 Control)
GetRouteUrl(String, Object)

ルート パラメーターのセットおよびルート名に対応する URL を取得します。

(継承元 Control)
GetRouteUrl(String, RouteValueDictionary)

ルート パラメーターのセットおよびルート名に対応する URL を取得します。

(継承元 Control)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
GetUniqueIDRelativeTo(Control)

指定されたコントロールの UniqueID プロパティのプレフィックス部分を返します。

(継承元 Control)
GetWebPart(WebPartDescription)

メソッドに渡される説明の値に基づいて、WebPart コントロールへの参照を返します。

HasControls()

サーバー コントロールに子コントロールが含まれているかどうかを確認します。

(継承元 Control)
HasEvents()

コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。

(継承元 Control)
IsLiteralContent()

サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。

(継承元 Control)
LoadControlState(Object)

SaveControlState() メソッドによって保存された前回のページ要求からコントロールの状態情報を復元します。

(継承元 Control)
LoadViewState(Object)

SaveViewState() メソッドで保存された前の要求からビュー ステート情報を復元します。

(継承元 WebControl)
MapPathSecure(String)

仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。

(継承元 Control)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MergeStyle(Style)

指定したスタイルの空白以外の要素を Web コントロールにコピーしますが、コントロールの既存のスタイル要素は上書きしません。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
OnBubbleEvent(Object, EventArgs)

サーバー コントロールのイベントをページの UI サーバー コントロールの階層構造に渡すかどうかを決定します。

(継承元 Control)
OnDataBinding(EventArgs)

DataBinding イベントを発生させます。

(継承元 Control)
OnInit(EventArgs)

Init イベントを発生させます。

(継承元 Control)
OnLoad(EventArgs)

Load イベントを発生させます。

(継承元 Control)
OnPreRender(EventArgs)

PreRender イベントを発生させます。

(継承元 CatalogPart)
OnUnload(EventArgs)

Unload イベントを発生させます。

(継承元 Control)
OpenFile(String)

ファイルの読み込みで使用される Stream を取得します。

(継承元 Control)
RaiseBubbleEvent(Object, EventArgs)

イベントのソースおよびその情報をコントロールの親に割り当てます。

(継承元 Control)
RemovedControl(Control)

Control オブジェクトの Controls コレクションから子コントロールが削除された後に呼び出されます。

(継承元 Control)
Render(HtmlTextWriter)

指定された HTML ライターにコントロールを描画します。

(継承元 WebControl)
RenderBeginTag(HtmlTextWriter)

Panel コントロールの HTML 開始タグを指定したライターに表示します。

(継承元 Panel)
RenderChildren(HtmlTextWriter)

提供された HtmlTextWriter オブジェクトに対してサーバー コントロールの子のコンテンツを出力すると、クライアントで表示されるコンテンツが記述されます。

(継承元 Control)
RenderContents(HtmlTextWriter)

コントロールの内容を指定したライターに出力します。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
RenderControl(HtmlTextWriter)

指定の HtmlTextWriter オブジェクトにサーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を保存します。

(継承元 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

指定した ControlAdapter オブジェクトを使用して、指定した HtmlTextWriter オブジェクトにサーバー コントロールの内容を出力します。

(継承元 Control)
RenderEndTag(HtmlTextWriter)

Panel コントロールの HTML 終了タグを指定したライターに表示します。

(継承元 Panel)
ResolveAdapter()

指定したコントロールを表示するコントロール アダプターを取得します。

(継承元 Control)
ResolveClientUrl(String)

ブラウザーで使用できる URL を取得します。

(継承元 Control)
ResolveUrl(String)

要求側クライアントで使用できる URL に変換します。

(継承元 Control)
SaveControlState()

ページがサーバーにポスト バックされた時間以降に発生したすべてのサーバー コントロール状態の変化を保存します。

(継承元 Control)
SaveViewState()

TrackViewState() メソッドが呼び出された後に変更された状態を保存します。

(継承元 WebControl)
SetDesignModeState(IDictionary)

コントロールのデザイン時データを設定します。

(継承元 CatalogPart)
SetRenderMethodDelegate(RenderMethod)

サーバー コントロールとその内容を親コントロールに表示するイベント ハンドラー デリゲートを割り当てます。

(継承元 Control)
SetTraceData(Object, Object)

トレース データ キーとトレース データ値を使用して、レンダリング データのデザイン時トレースのトレース データを設定します。

(継承元 Control)
SetTraceData(Object, Object, Object)

トレースされたオブジェクト、トレース データ キー、およびトレース データ値を使用して、レンダリング データのデザイン時トレースのトレース データを設定します。

(継承元 Control)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
TrackViewState()

コントロールでそのビュー ステートの変化を追跡して、その変化をオブジェクトの ViewState プロパティに保存できるようにします。

(継承元 WebControl)

イベント

DataBinding

サーバー コントロールがデータ ソースに連結すると発生します。

(継承元 Control)
Disposed

サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。

(継承元 Control)
Init

サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。

(継承元 Control)
Load

サーバー コントロールが Page オブジェクトに読み込まれると発生します。

(継承元 Control)
PreRender

Control オブジェクトの読み込み後、表示を開始する前に発生します。

(継承元 Control)
Unload

サーバー コントロールがメモリからアンロードされると発生します。

(継承元 Control)

明示的なインターフェイスの実装

IAttributeAccessor.GetAttribute(String)

指定された名前の Web コントロールの属性を取得します。

(継承元 WebControl)
IAttributeAccessor.SetAttribute(String, String)

Web コントロールの属性を指定された名前と値に設定します。

(継承元 WebControl)
ICompositeControlDesignerAccessor.RecreateChildControls()

複合パーツ コントロールのデザイナーの開発者が、デザイン サーフェイスでコントロールの子コントロールを再作成できるようにします。

(継承元 Part)
IControlBuilderAccessor.ControlBuilder

このメンバーの詳細については、「ControlBuilder」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.GetDesignModeState()

このメンバーの詳細については、「GetDesignModeState()」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

このメンバーの詳細については、「SetDesignModeState(IDictionary)」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

このメンバーの詳細については、「SetOwnerControl(Control)」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.UserData

このメンバーの詳細については、「UserData」をご覧ください。

(継承元 Control)
IDataBindingsAccessor.DataBindings

このメンバーの詳細については、「DataBindings」をご覧ください。

(継承元 Control)
IDataBindingsAccessor.HasDataBindings

このメンバーの詳細については、「HasDataBindings」をご覧ください。

(継承元 Control)
IExpressionsAccessor.Expressions

このメンバーの詳細については、「Expressions」をご覧ください。

(継承元 Control)
IExpressionsAccessor.HasExpressions

このメンバーの詳細については、「HasExpressions」をご覧ください。

(継承元 Control)
IParserAccessor.AddParsedSubObject(Object)

このメンバーの詳細については、「AddParsedSubObject(Object)」をご覧ください。

(継承元 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)

指定されたデータ コントロールの動的データの動作を有効にします。

適用対象

こちらもご覧ください