WebPartManager.EditDisplayMode フィールド
アセンブリ: System.Web (system.web.dll 内)


EditDisplayMode フィールドは、WebPartManager コントロールによって作成され格納された、カスタム WebPartDisplayMode オブジェクトを参照します。これは静的オブジェクトであるため、このコントロールのインスタンスがなくても、WebPartManager クラスを通じて直接このオブジェクトを参照できます。
Web パーツ コントロールが含まれたページを初めて読み込むと、既定で BrowseDisplayMode (ブラウズ モード) になります。ユーザーがサーバー コントロールを編集または変更する場合、最初にページを EditDisplayMode (編集モード) に切り替える必要があります。次に、編集する特定のサーバー コントロールのヘッダーにある動詞メニューの Edit 動詞をクリックし、そのコントロールを選択します。コントロールが編集モードになると、選択したコントロールを編集するための編集用ユーザー インターフェイス (UI) が表示されます。
ページ上で編集モードを有効にするには、LayoutEditorPart コントロール、カスタム編集コントロールなど、用意された編集コントロールを 1 つ以上格納する EditorZone ゾーンが少なくとも 1 つ、ページに含まれている必要があります。

プログラムを使用した EditDisplayMode フィールドの操作方法を次のコード例に示します。このコードは、ページでサポートされる表示モード (ここでは、ブラウズ モード、デザイン モード、および編集モード) でドロップダウン リストを生成します。編集をサポートするため、ページに <asp:EditorZone> 要素が存在します。Page_PreRender メソッドで、コードは現在の DisplayMode プロパティが EditDisplayMode に設定されているかどうかをチェックします。設定されている場合は Label1 が表示され、設定されていない場合は Label1 が非表示になります。
<%@ 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.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.EditDisplayMode) Then Label1.Visible = True Else Label1.Visible = False 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:Label ID="Label1" runat="server" Text="Currently in Edit Mode" Font-Bold="true" Font-Size="125%" /> <br /> <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.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.EditDisplayMode) 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: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:Label ID="Label1" runat="server" Text="Currently in Edit Mode" Font-Bold="true" Font-Size="125%" /> <br /> <asp:DropDownList ID="DisplayModeDropdown" runat="server" AutoPostBack="true" Width="120" OnSelectedIndexChanged= "DisplayModeDropdown_SelectedIndexChanged"> </asp:DropDownList> </div> </form> </body> </html>
ブラウザにページを読み込んだ後、既定でブラウズ モードになります。ページ上のラベルは非表示になっています。ドロップダウン リスト コントロールを使用して、ページを編集モードに切り替えます。Page_PreRender メソッドのコードに従って、ここではラベルが表示されます。いずれかのコントロールの動詞メニューの [編集] 動詞をクリックし、特定のコントロールの編集を有効にします。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebPartManager.EditDisplayMode フィールドを検索する場合は、下記のリンクをクリックしてください。

- WebPartManager.EditDisplayMode フィールドのページへのリンク