WebPartManager.DisplayModes プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As WebPartManager Dim value As WebPartDisplayModeCollection value = instance.DisplayModes
public: property WebPartDisplayModeCollection^ DisplayModes { WebPartDisplayModeCollection^ get (); }
WebPartManager コントロールに関連付けられた WebPartDisplayMode オブジェクトのセットが格納された WebPartDisplayModeCollection。

DisplayModes プロパティは、関連付けられたすべての表示モードを参照します。これは、現在のページで利用できる (サポートされている) 表示モードのみを参照する SupportedDisplayModes プロパティと対照的です。
用意されているブラウズとデザインの 2 つの表示モードは、ページ上で必ずサポートされます。他の 3 つの表示モード (編集、カタログ、および接続) は、その表示モードの動作に必要な種類のゾーンがページに存在する場合にのみサポートされます。たとえば、ページに EditorZone ゾーンが含まれていない場合、編集表示モードは DisplayModes プロパティで参照されるコレクションに表示されますが、SupportedDisplayModes プロパティで参照されるコレクションには表示されません。

DisplayModes プロパティのプログラムでの使用方法を示すコード例を次に示します。このコードは、表示モードが現在のページでサポートされていない場合でも、このプロパティを使用して Web パーツ コントロール セットで使用可能なすべての表示モードのリストを生成します。この場合、カタログ表示モードと接続表示モードは、必須となる対応ゾーンがページ上に存在しないためサポートされていません。
その他の 3 つの表示モード (ブラウズ、デザイン、および編集) が、このページでサポートされます。編集モードは、ページに EditorZone ゾーンが含まれているためサポートされます。一方、ブラウズ モードとデザイン モードは常にサポートされます。
ブラウザにページを読み込んだ後、ドロップダウン リスト コントロールを使用して、ブラウズ モードからデザイン モードにページを切り替え、次に編集モードに切り替えることができます。編集モードで、サーバー コントロールの 1 つのヘッダーにあるドロップダウンの動詞メニューをクリックし、[編集] を選択してコントロールを編集します。ドロップダウン リストの [カタログ] または [接続] を選択すると、エラー ページが生成されます。
<%@ Page Language="VB" %> <script runat="server"> Protected Sub Page_Init(ByVal sender As Object, _ ByVal e As EventArgs) Dim mode As WebPartDisplayMode For Each mode In mgr.DisplayModes 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.DisplayModes(selectedMode) If mode IsNot Nothing Then mgr.DisplayMode = mode End If End Sub </script> <html > <head runat="server"> </head> <body> <form id="form1" runat="server"> <div> <asp:WebPartManager ID="mgr" runat="server"> </asp:WebPartManager> <asp:WebPartZone ID="WebPartZone1" runat="server"> <ZoneTemplate> <asp:Calendar ID="Calendar1" runat="server" Title="My Calendar" /> </ZoneTemplate> </asp:WebPartZone> <asp:WebPartZone ID="WebPartZone2" runat="server"> <ZoneTemplate> <asp:BulletedList DisplayMode="HyperLink" ID="BulletedList1" runat="server" Title="My Links"> <asp:ListItem Value="http://www.microsoft.com"> Microsoft </asp:ListItem> <asp:ListItem Value="http://www.msn.com"> MSN </asp:ListItem> <asp:ListItem Value="http://www.contoso.com"> Contoso Corp. </asp:ListItem> </asp:BulletedList> </ZoneTemplate> </asp:WebPartZone> <asp:EditorZone ID="EditorZone1" runat="server"> <ZoneTemplate> <asp:AppearanceEditorPart runat="server" ID="Appearance1"> </asp:AppearanceEditorPart> <asp:LayoutEditorPart runat="server" ID="Layout1"> </asp:LayoutEditorPart> </ZoneTemplate> </asp:EditorZone> <hr /> <asp:DropDownList ID="DisplayModeDropdown" runat="server" AutoPostBack="true" Width="120" OnSelectedIndexChanged= "DisplayModeDropdown_SelectedIndexChanged"> </asp:DropDownList> </div> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> protected void Page_Init(object sender, EventArgs e) { foreach (WebPartDisplayMode mode in mgr.DisplayModes) { 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.DisplayModes[selectedMode]; if (mode != null) mgr.DisplayMode = mode; } </script> <html > <head runat="server"> </head> <body> <form id="form1" runat="server"> <div> <asp:WebPartManager ID="mgr" runat="server"> </asp:WebPartManager> <asp:WebPartZone ID="WebPartZone1" runat="server"> <ZoneTemplate> <asp:Calendar ID="Calendar1" runat="server" Title="My Calendar" /> </ZoneTemplate> </asp:WebPartZone> <asp:WebPartZone ID="WebPartZone2" runat="server"> <ZoneTemplate> <asp:BulletedList DisplayMode="HyperLink" ID="BulletedList1" runat="server" Title="My Links"> <asp:ListItem Value="http://www.microsoft.com"> Microsoft </asp:ListItem> <asp:ListItem Value="http://www.msn.com"> MSN </asp:ListItem> <asp:ListItem Value="http://www.contoso.com"> Contoso Corp. </asp:ListItem> </asp:BulletedList> </ZoneTemplate> </asp:WebPartZone> <asp:EditorZone ID="EditorZone1" runat="server"> <ZoneTemplate> <asp:AppearanceEditorPart runat="server" ID="Appearance1"> </asp:AppearanceEditorPart> <asp:LayoutEditorPart runat="server" ID="Layout1"> </asp:LayoutEditorPart> </ZoneTemplate> </asp:EditorZone> <hr /> <asp:DropDownList ID="DisplayModeDropdown" runat="server" AutoPostBack="true" Width="120" OnSelectedIndexChanged= "DisplayModeDropdown_SelectedIndexChanged"> </asp:DropDownList> </div> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebPartManager クラス
WebPartManager メンバ
System.Web.UI.WebControls.WebParts 名前空間
WebPartManager.DisplayMode プロパティ
CreateDisplayModes
SupportedDisplayModes
その他の技術情報
ASP.NET Web パーツ ページ
Web パーツ ページの表示モード
チュートリアル : Web パーツ ページでの表示モードの変更
Weblioに収録されているすべての辞書からWebPartManager.DisplayModes プロパティを検索する場合は、下記のリンクをクリックしてください。

- WebPartManager.DisplayModes プロパティのページへのリンク