WebPartManager.ConnectDisplayMode フィールドとは? わかりやすく解説

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

WebPartManager.ConnectDisplayMode フィールド

メモ : このフィールドは、.NET Framework version 2.0新しく追加されたものです。

ユーザーWebPart コントロール間の接続管理するための特殊なユーザー インターフェイス (UI) を表示する場合使用する表示モード表します。このフィールド読み取り専用です。

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

Public Shared ReadOnly ConnectDisplayMode
 As WebPartDisplayMode
Dim value As WebPartDisplayMode

value = WebPartManager.ConnectDisplayMode
public static readonly WebPartDisplayMode ConnectDisplayMode
public:
static initonly WebPartDisplayMode^ ConnectDisplayMode
public static final WebPartDisplayMode ConnectDisplayMode
public static final var
 ConnectDisplayMode : WebPartDisplayMode
解説解説
使用例使用例

ConnectDisplayMode モード使用方法次のコード例示します

コード例は、次の 3 つの部分から成ります

このコード例最初部分は、1 つインターフェイスおよび接続できるようにデザインされ2 つカスタム WebPart コントロールを含むソース ファイルです。コード例実行するためには、このソース コードコンパイルする必要があります。それを明示的にコンパイルし、コンパイル済みアセンブリWeb サイトBin フォルダまたはグローバル アセンブリ キャッシュ配置できますサイトの App_Code フォルダソース コード配置し実行時動的にコンパイルすることもできます。このコード例は、動的コンパイルアプローチ使用しますコンパイル方法を示すチュートリアルについては、「チュートリアル : カスタム サーバー コントロール開発と使用」を参照してください

Imports System
Imports System.Web
Imports System.Web.Security
Imports System.Security.Permissions
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 Interface IZipCode

    Property ZipCode() As String

  End Interface

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class ZipCodeWebPart
    Inherits WebPart
    Implements IZipCode
    Private zipCodeText As String
 = String.Empty
    Private input As TextBox
    Private send As Button

    Public Sub New()
    End Sub

    ' Make the implemented property personalizable to save 
    ' the Zip Code between browser sessions.
    <Personalizable()> _
    Public Property ZipCode() As
 String _
      Implements IZipCode.ZipCode

      Get
        Return zipCodeText
      End Get
      Set(ByVal value As
 String)
        zipCodeText = value
      End Set
    End Property

    ' This is the callback method that returns the provider.
    <ConnectionProvider("Zip Code", "ZipCodeProvider")>
 _
    Public Function ProvideIZipCode() As
 IZipCode
      Return Me
    End Function


    Protected Overrides Sub
 CreateChildControls()
      Controls.Clear()
      input = New TextBox()
      Me.Controls.Add(input)
      send = New Button()
      send.Text = "Enter 5-digit Zip Code"
      AddHandler send.Click, AddressOf Me.submit_Click
      Me.Controls.Add(send)

    End Sub


    Private Sub submit_Click(ByVal
 sender As Object, _
      ByVal e As EventArgs)

      If input.Text <> String.Empty Then
        zipCodeText = Page.Server.HtmlEncode(input.Text)
        input.Text = String.Empty
      End If

    End Sub

  End Class

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class WeatherWebPart
    Inherits WebPart
    Private _provider As IZipCode
    Private _zipSearch As String
    Private DisplayContent As Label

    ' This method is identified by the ConnectionConsumer 
    ' attribute, and is the mechanism for connecting with 
    ' the provider. 
    <ConnectionConsumer("Zip Code", "ZipCodeConsumer")>
 _
    Public Sub GetIZipCode(ByVal
 Provider As IZipCode)
      _provider = Provider
    End Sub


    Protected Overrides Sub
 OnPreRender(ByVal e As EventArgs)
      EnsureChildControls()

      If Not (Me._provider
 Is Nothing) Then
        _zipSearch = _provider.ZipCode.Trim()
                DisplayContent.Text = "My Zip Code is:  "
 + _zipSearch
      End If

    End Sub 'OnPreRender

    Protected Overrides Sub
 CreateChildControls()
      Controls.Clear()
      DisplayContent = New Label()
      Me.Controls.Add(DisplayContent)

    End Sub

  End Class

End Namespace
namespace Samples.AspNet.CS.Controls
{
  using System;
  using System.Web;
  using System.Web.Security;
  using System.Security.Permissions;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public interface IZipCode
  {
    string ZipCode { get; set;}
  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class ZipCodeWebPart : WebPart, IZipCode
  {
    string zipCodeText = String.Empty;
    TextBox input;
    Button send;

    public ZipCodeWebPart()
    {
    }

    // Make the implemented property personalizable to save 
    // the Zip Code between browser sessions.
    [Personalizable()]
    public virtual string ZipCode
    {
      get { return zipCodeText; }
      set { zipCodeText = value; }
    }

    // This is the callback method that returns the provider.
    [ConnectionProvider("Zip Code", "ZipCodeProvider")]
    public IZipCode ProvideIZipCode()
    {
      return this;
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      input = new TextBox();
      this.Controls.Add(input);
      send = new Button();
      send.Text = "Enter 5-digit Zip Code";
      send.Click += new EventHandler(this.submit_Click);
      this.Controls.Add(send);
    }

    private void submit_Click(object sender,
 EventArgs e)
    {
      if (input.Text != String.Empty)
      {
        zipCodeText = Page.Server.HtmlEncode(input.Text);
        input.Text = String.Empty;
      }
    }

  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class WeatherWebPart : WebPart
  {
    private IZipCode _provider;
    string _zipSearch;
    Label DisplayContent;

    // This method is identified by the ConnectionConsumer 
    // attribute, and is the mechanism for connecting with 
    // the provider. 
    [ConnectionConsumer("Zip Code", "ZipCodeConsumer")]
    public void GetIZipCode(IZipCode Provider)
    {
      _provider = Provider;
    }
    
    protected override void OnPreRender(EventArgs
 e)
    {
      EnsureChildControls();

      if (this._provider != null)
      {
        _zipSearch = _provider.ZipCode.Trim();
        DisplayContent.Text = "My Zip Code is:  " + _zipSearch;
      }
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      DisplayContent = new Label();
      this.Controls.Add(DisplayContent);
    }

  }
}

コード例2 番目の部分は、カスタム コントロールホストする Web ページです。ページ上のサーバー<script> タグ内には、そのページ上で使用できる表示モードドロップダウン リスト生成するいくつかのメソッドありますユーザードロップダウン リストから表示モード選択してページ表示モード変更できますページマークアップ<asp:connectionszone> 要素宣言されているため、接続表示モード使用できます。この要素には、他の子要素含まれていません。この要素は、ユーザー用の接続管理 UI有効にするためにだけ存在します

この例では、ConnectDisplayMode モード2 つの場所で表示されます。1 つ目は、Page_Init メソッドで、コードは SupportedDisplayModes プロパティ参照されるコレクションループ処理し接続表示モード表示モードドロップダウン リスト追加します2 つ目は、Page_PreRender メソッドページ上の現在の表示モードチェックし現在のモードConnectDisplayMode場合Label コントロールメッセージ表示します

<%@ Page Language="vb" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.VB.Controls"
 %>

<script runat="server">
  
  Protected Sub Page_Init(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    Dim mode As WebPartDisplayMode
    For Each mode In mgr.SupportedDisplayModes
      Dim modeName As String
 = mode.Name
      If mode.IsEnabled(mgr) Then
        Dim item As ListItem = New
 ListItem(modeName, modeName)
        DisplayModeDropdown.Items.Add(item)
      End If
    Next
    
  End Sub

  Protected Sub DisplayModeDropdown_SelectedIndexChanged(ByVal
 _
    sender As Object, ByVal
 e As EventArgs)
    
    Dim selectedMode As String
 = _
      DisplayModeDropdown.SelectedValue
    Dim mode As WebPartDisplayMode = _
      mgr.SupportedDisplayModes(selectedMode)
    If mode IsNot Nothing Then
      mgr.DisplayMode = mode
    End If
    
  End Sub
  
  Protected Sub Page_PreRender(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    If mgr.DisplayMode.Equals(WebPartManager.ConnectDisplayMode)
 Then
      Label1.Visible = True
    Else
      Label1.Visible = False
    End If
  End Sub
  
</script>

<html  >
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="mgr" runat="server"
 />    
      <asp:Label ID="Label1" runat="server"
 
        Text="Currently in Connect Display Mode" 
        Font-Bold="true"
        Font-Size="125%" />
      <br />
      <asp:DropDownList ID="DisplayModeDropdown"
 
        runat="server" 
        AutoPostBack="true"
        Width="120"
        OnSelectedIndexChanged=
        "DisplayModeDropdown_SelectedIndexChanged">
      </asp:DropDownList>
      <hr />
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" runat="server"
            Title="Zip Code Provider" />
          <aspSample:WeatherWebPart ID="weather1"
 runat="server" 
            Title="Zip Code Consumer" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:ConnectionsZone ID="ConnectionsZone1"
 runat="server" />
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.CS.Controls" %>

<script runat="server">

  protected void Page_Init(object sender, EventArgs
 e)
  {
    foreach (WebPartDisplayMode mode in mgr.SupportedDisplayModes)
    {
      string modeName = mode.Name;
      if (mode.IsEnabled(mgr))
      {
        ListItem item = new ListItem(modeName, modeName);
        DisplayModeDropdown.Items.Add(item);
      }      
    }
  }

  protected void DisplayModeDropdown_SelectedIndexChanged(object
 
    sender, EventArgs e)
  {
    String selectedMode = DisplayModeDropdown.SelectedValue;
    WebPartDisplayMode mode = 
      mgr.SupportedDisplayModes[selectedMode];
    if (mode != null)
      mgr.DisplayMode = mode;
  }

  protected void Page_PreRender(object sender,
 EventArgs e)
  {
    if (mgr.DisplayMode == WebPartManager.ConnectDisplayMode)
      Label1.Visible = true;
    else
      Label1.Visible = false;
  }
  
</script>

<html  >
<head runat="server">
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="mgr" runat="server" />  
  
      <asp:Label ID="Label1" runat="server" 
        Text="Currently in Connect Display Mode" 
        Font-Bold="true"
        Font-Size="125%" />
      <br />
      <asp:DropDownList ID="DisplayModeDropdown" 
        runat="server" 
        AutoPostBack="true"
        Width="120"
        OnSelectedIndexChanged=
        "DisplayModeDropdown_SelectedIndexChanged">
      </asp:DropDownList>
      <hr />
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" runat="server"
            Title="Zip Code Provider" />
          <aspSample:WeatherWebPart ID="weather1" runat="server"
 
            Title="Zip Code Consumer" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:ConnectionsZone ID="ConnectionsZone1" runat="server"
 />
    </div>
    </form>
</body>
</html>

ブラウザページ読み込んだ後、ドロップダウン リストクリックし、[接続] を選択してページ接続表示モード切り替えますページ接続表示モードにあることを伝えメッセージ表示されます。いずれかWebPart コントロールタイトル バーにある動詞メニュー (矢印記号) をクリックし動詞メニューの [接続] をクリックします。接続 UI表示されたら、リンクをクリックして接続作成します表示される接続 UI 内のドロップダウン リスト使用して、この接続関係するもう一方コントロール選択し、[接続] をクリックします。接続確立されます。[閉じる] をクリックしページ先頭にあるドロップダウン リスト使用してページブラウズ表示モード戻します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebPartManager クラス
WebPartManager メンバ
System.Web.UI.WebControls.WebParts 名前空間
DisplayModes
WebPartDisplayMode クラス
その他の技術情報
ASP.NET Web パーツ ページ
Web パーツ ページ表示モード


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

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

辞書ショートカット

すべての辞書の索引

WebPartManager.ConnectDisplayMode フィールドのお隣キーワード
検索ランキング

   

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



WebPartManager.ConnectDisplayMode フィールドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS