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

BehaviorEditorPart クラス

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

関連付けられた WebPart コントロール複数ユーザー インターフェイス (UI) プロパティエンド ユーザー編集できるようにするエディタ コントロール提供します。このクラス継承できません。

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

Public NotInheritable Class
 BehaviorEditorPart
    Inherits EditorPart
Dim instance As BehaviorEditorPart
public sealed class BehaviorEditorPart : EditorPart
public ref class BehaviorEditorPart sealed
 : public EditorPart
public final class BehaviorEditorPart extends
 EditorPart
public final class BehaviorEditorPart extends
 EditorPart
解説解説

BehaviorEditorPart クラスは、EditorPart クラスから派生するエディタ コントロールであり、関連付けられた WebPart コントロールまたは GenericWebPart コントロール動作影響するプロパティ編集使用されます。

Web パーツ コントロール セット (詳細については ToolZone クラス概要参照) 内にツール指向ゾーンあるように、ツール指向パーツ コントロール (ツール パーツ) があり、各ツール パーツ特定のタイプツール ゾーン配置する必要がありますWeb パーツ コントロール セットツール パーツには、2 つ際立った特性あります

BehaviorEditorPart コントロールは、Web パーツ ページ編集モード場合、および編集のために特定の WebPart コントロール選択されている場合にのみ表示されるツール パーツです。BehaviorEditorPart コントロールは、他のすべての EditorPart コントロール同じように、EditorZone コントロール配置されます。

メモ重要 :

EditorZone ゾーンには、EditorPart コントロールだけを格納できますEditorPart コントロールを他のタイプゾーン配置することはできません。

コントロールは、特定の状況ページには表示されません。編集中の WebPart コントロールの IsShared プロパティ値が true であり、ページユーザー パーソナル化スコープ (既定) にある場合コントロール表示されません。この場合BehaviorEditorPart コントロール表示するには、通常 2 つの手順に従う必要があります

BehaviorEditorPart コントロールページ表示できるようにする方法例については、このトピックの「使用例セクション参照してください共有コントロールおよびパーソナル化スコープ詳細については、「Web パーツパーソナル化概要」を参照してください

BehaviorEditorPart クラスには、SyncChanges という重要なメソッドあります。これは、EditorPart クラスおよびオーバーライドから継承されます。このメソッド重要なのは、編集中の WebPart コントロールかプロパティ値を取得してそれを編集中のコントロールフィールド代入できるからです。

ほとんどの場合BehaviorEditorPart コントロールページ内で永続形式使用する必要がありますこのためには、<asp:behavioreditorpart> 要素<zonetemplate> 要素内で宣言します。この要素Web ページ上の <asp:editorzone> 要素によって格納されます。BehaviorEditorPart コントロール使用してエンド ユーザーは、次に示す WebPart コントロールUI プロパティ編集できます

  • Description

  • TitleUrl

  • TitleIconImageUrl

  • CatalogIconImageUrl

  • HelpUrl

  • HelpMode

  • ImportErrorMessage

  • ExportMode

  • AuthorizationFilter

  • AllowClose

  • AllowConnect

  • AllowEdit

  • AllowHide

  • AllowMinimize

  • AllowZoneChange

WebPart コントロールプロパティおよび動作編集するために、Web パーツ コントロール セット提供される他の EditorPart コントロール使用できます。これらのコントロールには、LayoutEditorPart、AppearanceEditorPart、PropertyGridEditorPart などのコントロールあります提供されている EditorPart コントロールでは、WebPart コントロール編集必要な編集機能のほとんどが提供されますが、EditorPart クラスから継承する方法カスタムエディタ コントロール作成することもできますコード例については、EditorPart クラス概要参照してください

ユーザー補助

使用例使用例

Web ページ内で BehaviorEditorPart コントロール宣言し、それによって WebPart コントロール複数UI プロパティ編集できるようにする方法次のコード例示しますコード例は、次の 4 つ部分から成ります

コード例最初部分は、Web ページ上の表示モードユーザー変更できるようにするユーザー コントロールです。表示モード詳細、およびこのコントロールソース コード説明については、「チュートリアル : Web パーツ ページでの表示モード変更」を参照してください。このユーザー コントロールドキュメントには、ToggleScope メソッド呼び出してページBehaviorEditorPart コントロール表示できる共有モード切り替える方法説明されています。

<%@ 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 ページです。ここには、EditorZone コントロールへの宣言参照、および子の <zonetemplate> 要素含まれます。この子要素には BehaviorEditorPart コントロールへの宣言参照含まれています。ページには、Pubs データベースバインドされた BulletedList コントロール含まれています。このコントロールは WebPartZone に配置されているので、BehaviorEditorPart コントロール編集できる WebPart コントロールとして機能できます

<%@ Page Language="VB" %>
<%@ Register Src="~/displayModeMenuVB.ascx" 
  TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" %>

<script runat="server">

  Protected Sub Page_Load(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    Button1.Visible = False
    TextBox1.Visible = False
    BulletedList1.DataBind()
  End Sub

  Protected Sub Button1_Click(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    BehaviorEditorPart1.Title = Server.HtmlEncode(TextBox1.Text)
  End Sub

  Protected Sub BehaviorEditorPart1_PreRender(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
   
    Button1.Visible = True
    TextBox1.Visible = True
    
  End Sub
</script>

<html  >
<head runat="server">
</head>
<body>
  <form id="form1" runat="server">
    <!-- This example uses Microsoft SQL Server and connects
    -->
    <!-- to the Pubs sample database. Use an ASP.NET expression
 -->
    <!-- like the one in the following control
 to retrieve the  -->
    <!-- connection string value from the Web.config file.
      -->
    <asp:SqlDataSource ID="ds1" runat="server"
 
      connectionString="<%$ ConnectionStrings:PubsConnection
 %>" 
      SelectCommand="Select au_id, au_lname, au_fname From Authors"/>
    <asp:WebPartManager ID="WebPartManager1" runat="server"
 />
    <uc1:DisplayModeMenuVB id="menu1" runat="server"
 />
    <asp:WebPartZone ID="WebPartZone1" runat="server"
 Width="150" 
      style="z-index: 100; left: 10px; position: absolute; top:
 90px" >
      <ZoneTemplate>
        <asp:Panel ID="panel1" runat="server"
 Title="Author List WebPart">
          <asp:Label ID="Label1" runat="server"
 
            Text="Author Names" 
            Font-Bold="true" 
            Font-Size="120%"/>
          <asp:BulletedList ID="BulletedList1"
 runat="server" 
            DataSourceID="ds1" 
            DataTextField="au_lname" 
            DataValueField="au_id"/>
        </asp:Panel>
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:WebPartZone ID="WebPartZone2" runat="server"
 Width="150" 
      style="z-index: 101; left: 170px; position: absolute; top:
 90px" />
    <asp:EditorZone ID="EditorZone1" runat="server"
 
      style="z-index: 102; left: 340px; position: absolute; top:
 90px" 
      Width="170px">
      <ZoneTemplate>
        <asp:BehaviorEditorPart ID="BehaviorEditorPart1"
 runat="server" 
          Title="My BehaviorEditorPart"  
          OnPreRender="BehaviorEditorPart1_PreRender"
 />
      </ZoneTemplate>
    </asp:EditorZone>
    <asp:Button ID="Button1" runat="server"
 Width="140" 
      Text="Update EditorPart Title" 
      style="left: 340px; position: absolute; top: 65px; z-index:
 103;" 
      OnClick="Button1_Click" />
    <asp:TextBox ID="TextBox1" runat="server"
 
      style="z-index: 105; left: 500px; position: absolute; top:
 65px" />
  </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ Register Src="~/displayModeMenuCS.ascx" 
  TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" %>

<script runat="server">

  protected void Page_Load(object sender, EventArgs
 e)
  {
    Button1.Visible = false;
    TextBox1.Visible = false;
    BulletedList1.DataBind();
  }

  protected void Button1_Click(object sender,
 EventArgs e)
  {
    BehaviorEditorPart1.Title = Server.HtmlEncode(TextBox1.Text);
  }

  protected void BehaviorEditorPart1_PreRender(object
 sender, 
    EventArgs e)
  {
    Button1.Visible = true;
    TextBox1.Visible = true;
  }
</script>

<html  >
<head runat="server">
</head>
<body>
  <form id="form1" runat="server">
    <!-- This example uses Microsoft SQL Server and connects    -->
    <!-- to the Pubs sample database. Use an ASP.NET expression -->
    <!-- like the one in the following control to retrieve
 the  -->
    <!-- connection string value from the Web.config file.
      -->
    <asp:SqlDataSource ID="ds1" runat="server" 
      connectionString="<%$ ConnectionStrings:PubsConnection %>"
 
      SelectCommand="Select au_id, au_lname, au_fname From Authors"/>
    <asp:WebPartManager ID="WebPartManager1" runat="server"
 />
    <uc1:DisplayModeMenuCS id="menu1" runat="server" />
    <asp:WebPartZone ID="WebPartZone1" runat="server" Width="150"
 
      style="z-index: 100; left: 10px; position: absolute; top: 90px" >
      <ZoneTemplate>
        <asp:Panel ID="panel1" runat="server" Title="Author
 List WebPart">
          <asp:Label ID="Label1" runat="server" 
            Text="Author Names" 
            Font-Bold="true" 
            Font-Size="120%"/>
          <asp:BulletedList ID="BulletedList1" runat="server"
 
            DataSourceID="ds1" 
            DataTextField="au_lname" 
            DataValueField="au_id"/>
        </asp:Panel>
      </ZoneTemplate>
    </asp:WebPartZone>
    <asp:WebPartZone ID="WebPartZone2" runat="server" Width="150"
 
      style="z-index: 101; left: 170px; position: absolute; top: 90px"
 />
    <asp:EditorZone ID="EditorZone1" runat="server" 
      style="z-index: 102; left: 340px; position: absolute; top: 90px"
 
      Width="170px">
      <ZoneTemplate>
        <asp:BehaviorEditorPart ID="BehaviorEditorPart1" runat="server"
 
          Title="My BehaviorEditorPart"  
          OnPreRender="BehaviorEditorPart1_PreRender" />
      </ZoneTemplate>
    </asp:EditorZone>
    <asp:Button ID="Button1" runat="server" Width="140"
 
      Text="Update EditorPart Title" 
      style="left: 340px; position: absolute; top: 65px; z-index: 103;"
 
      OnClick="Button1_Click" />
    <asp:TextBox ID="TextBox1" runat="server" 
      style="z-index: 105; left: 500px; position: absolute; top: 65px"
 />
  </form>
</body>
</html>

コード例3 番目の部分は、Web.config ファイル内のエントリです。ファイル<webParts> セクションに、次のようなエントリを作成して承認されユーザーまたはユーザー セットが、Web ページ共有パーソナル化スコープにある場合にそれを編集できるようにする必要があります。このエントリは、重要なステップです。これがない場合ページ編集モード切り替えてBehaviorEditorPart コントロール表示されません。

<webParts>

<personalization>

<authorization>

<allow users="User_account" roles="admin"

verbs="enterSharedScope"/>

</authorization>

</personalization>

</webParts>

ブラウザページ読み込む場合は、まず [Display Mode] ドロップダウン リスト コントロールの [共有] オプション選択できます次にドロップダウン リスト自体クリックし、[編集モード] を選択してページ編集モード切り替えますAuthor List WebPart コントロールタイトル バー動詞メニュー (下向き矢印) をクリックし、[編集] をクリックすることにより、コントロール編集できます編集中の UI表示状態の場合BehaviorEditorPart コントロール表示されボタンおよびテキスト ボックスその上に配置されます。編集中の UI変更行い、[適用] ボタンクリックした場合、[Display Mode] ドロップダウン リスト コントロール使用してページブラウズ モード戻し編集中の変更をすべて反映した結果表示できます

.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.EditorPart
            System.Web.UI.WebControls.WebParts.BehaviorEditorPart
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BehaviorEditorPart メンバ
System.Web.UI.WebControls.WebParts 名前空間
AppearanceEditorPart クラス
LayoutEditorPart
PropertyGridEditorPart
その他の技術情報
Web パーツパーソナル化概要
ASP.NET Web パーツ ページ



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

辞書ショートカット

すべての辞書の索引

「BehaviorEditorPart クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS