WebPart.AllowHide プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebPart.AllowHide プロパティの意味・解説 

WebPart.AllowHide プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

エンド ユーザーWebPart コントロールを非表示にできるかどうかを示す値を取得または設定します

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

<ThemeableAttribute(False)> _
Public Overridable Property
 AllowHide As Boolean
Dim instance As WebPart
Dim value As Boolean

value = instance.AllowHide

instance.AllowHide = value
[ThemeableAttribute(false)] 
public virtual bool AllowHide { get;
 set; }
[ThemeableAttribute(false)] 
public:
virtual property bool AllowHide {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AllowHide ()

/** @property */
public void set_AllowHide (boolean value)

プロパティ
WebPart コントロールを非表示にできる場合trueそれ以外場合false既定値true です。

解説解説

AllowHide プロパティは、ユーザーHidden プロパティ変更できるかどうか決定します既定場合プロパティ値が true のとき、ユーザーコントロール編集中に値を変更できます既定では、コントロールは非表示ではありません。また、その Hidden プロパティ値は false です。WebPart コントロール編集中にユーザーコントロールを非表示にするチェック ボックスオンにする (Hidden プロパティtrue設定する) と、そのコントロールページブラウズ モード戻ったときに表示されなくなります

Hidden プロパティWeb パーツ コントロール内では特別な意味を持っているので、非表示コントロールは、終了したコントロールとは区別されます。終了したコントロールページレンダリングされず、ページ有効期限イベントにも参加しません。それとは対照的に、非表示WebPart コントロールユーザーには表示されなくても、Web ページにはレンダリングされており、ゾーンにもまだ格納されています。また、Web パーツ アプリケーション一部として、他の WebPart コントロールとの接続そのまま維持できます

このプロパティを、テーマまたはスタイル シート テーマ使用して設定することはできません。詳細については、ThemeableAttribute、ASP.NETテーマスキン概要 の各トピック参照してください

このプロパティパーソナル化スコープは Shared に設定され承認されユーザーだけが変更できます詳細については、PersonalizableAttribute、Web パーツパーソナル化概要 の各トピック参照してください

使用例使用例

カスタム Web パーツ コントロールAllowHide プロパティ既定設定変更してユーザーがそのカスタム コントロールを非表示できないようにする方法次のコード例示します。この例は、WebPart クラス概要の「使用例」にある TextDisplayWebPart というカスタム WebPart コントロール使用前提にしています。

コード例では、ユーザーWeb パーツ ページ上の表示モード変更できるようにするカスタム ユーザー コントロール使用しますユーザー コントロールは、それをホストする Web ページ先頭付近にある Register ディレクティブ使用して参照されます。このユーザー コントロール作成して表示モード操作する方法詳細については、「チュートリアル : カスタム サーバー コントロール開発と使用」を参照してください

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

Web ページ宣言マークアップで、コントロール参照する <aspSample:TextDisplayWebPart> 要素AllowHide="false" 属性確認します。この属性によって、コントロール編集しているユーザーはそれを非表示にできなくなりますブラウザページ読み込み、[Display Mode] ドロップダウン リスト コントロール使用して表示モード編集モード変更します次にWebPart コントロールタイトル バーにある動詞メニュークリックしedit 動詞クリックします。表示され編集ユーザー インターフェイス (UI) では、Hidden プロパティ編集するための UI無効になっています。これは、AllowHide プロパティ値を false設定した結果です。

<%@ page language="VB" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls"
 
  Assembly="TextDisplayWebPartVB"%>

<html>
<head id="Head1" runat="server">
  
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server"
 />
    <uc1:DisplayModeMenuVB ID="DisplayModeMenu1"
 runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc"
 />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart"
            AllowHide="false" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:EditorZone id="EditZone1" Runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="editor1"
 Runat="server" />
      </ZoneTemplate>
    </asp:EditorZone>
  </form>
</body>
</html>
<%@ page language="C#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" 
  Assembly="TextDisplayWebPartCS"%>

<html>
<head id="Head1" runat="server">
  
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server"
 />
    <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server"
 />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc"
 />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart"
            AllowHide="false" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:EditorZone id="EditZone1" Runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="editor1" Runat="server"
 />
      </ZoneTemplate>
    </asp:EditorZone>
  </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「WebPart.AllowHide プロパティ」の関連用語

WebPart.AllowHide プロパティのお隣キーワード
検索ランキング

   

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



WebPart.AllowHide プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS