WebPartZoneBase.HelpVerb プロパティ

定義

ゾーン内の WebPartVerb コントロールのヘルプの内容にアクセスするために使用される WebPart オブジェクトへの参照を取得します。

public:
 virtual property System::Web::UI::WebControls::WebParts::WebPartVerb ^ HelpVerb { System::Web::UI::WebControls::WebParts::WebPartVerb ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual System.Web.UI.WebControls.WebParts.WebPartVerb HelpVerb { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.HelpVerb : System.Web.UI.WebControls.WebParts.WebPartVerb
Public Overridable ReadOnly Property HelpVerb As WebPartVerb

プロパティ値

ユーザーがゾーン内の WebPartVerb コントロールのヘルプの内容にアクセスできるようにする WebPart

属性

次のコード例では、コントロールで プロパティを HelpVerb 使用する方法を WebPartZone 示します。

コード例を機能させるには、次のコードに加えて、カスタム WebPart コントロールが必要です。 独自のコントロールを使用することも、クラスの概要の「例」セクションにあるカスタム TextDisplayWebPart コントロールのコードを WebPart 使用することもできます。

このコード例には、Web ページの表示モードを変更できるようにするユーザー コントロールが含まれています。 このコントロールの表示モードとソース コードの詳細については、「 チュートリアル: Web パーツ ページでの表示モードの変更」を参照してください。

<%@ 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=" Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" 
      AssociatedControlID="DisplayModeDropdown"/>
    <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="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=" Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" 
      AssociatedControlID="DisplayModeDropdown"/>
    <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>

このコード例には、コントロールのヘルプ コンテンツ TextDisplayWebPart を含めることができる HTML ページも含まれています。 この例を機能させるには、次のコードを Textwebparthelp.htm という名前のファイルに保存し、コントロールをホストする .aspx ページと同じサイトのディレクトリに配置する TextDisplayWebPart 必要があります。

<html>  
<head runat="server">  
    <title>Text Content WebPart Help</title>  
</head>  
<body>  
  <div>  
  <h1>Text Content WebPart Help</h1>  
  To make the WebPart control work...  
  </div>  
</body>  
</html>  

このコード例には、.aspx ページのイベントを処理するコードを含む次の部分クラスも含まれています。

using System;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class WebPartZoneBase_verbs : System.Web.UI.Page
{
  protected void Page_Load(Object sender, EventArgs e)
  {
    if (WebPartZone1.WebParts.Count == 0)
      Table1.Visible = false;
    else
      Table1.Visible = true;

    // Enable all verbs on the first page load.
    if (!IsPostBack)
    {
      foreach (ListItem item in CheckBoxList1.Items)
        item.Selected = true;
      CheckBoxList1_SelectedItemIndexChanged(sender, e);
    } 
  }

  protected void CheckBoxList1_SelectedItemIndexChanged(Object sender, EventArgs e)
  {
    foreach (ListItem item in CheckBoxList1.Items)
    {
      WebPartVerb theVerb;
      switch (item.Value)
      {
        case "close":
          theVerb = WebPartZone1.CloseVerb;
          break;
        case "export":
          theVerb = WebPartZone1.ExportVerb;
          break;
        case "delete":
          theVerb = WebPartZone1.DeleteVerb;
          break;
        case "minimize":
          theVerb = WebPartZone1.MinimizeVerb;
          break;
        case "restore":
          theVerb = WebPartZone1.RestoreVerb;
          break;
        default:
          theVerb = null;
          break;
      }

      if (item.Selected)
        theVerb.Enabled = true;
      else
        theVerb.Enabled = false;
    }
  }
}
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts

Public Partial Class WebPartZoneBase_verbs

  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As [Object], ByVal e As EventArgs)
    If WebPartZone1.WebParts.Count = 0 Then
      Table1.Visible = False
    Else
      Table1.Visible = True
    End If

    ' Enable all verbs on the first page load.
    If Not IsPostBack Then
      Dim item As ListItem
      For Each item In CheckBoxList1.Items
        item.Selected = True
      Next item
      CheckBoxList1_SelectedItemIndexChanged(sender, e)
    End If
  End Sub
    
  Protected Sub CheckBoxList1_SelectedItemIndexChanged(ByVal sender As [Object], ByVal e As EventArgs)
    Dim item As ListItem
    For Each item In CheckBoxList1.Items
      Dim theVerb As WebPartVerb
      Select Case item.Value
        Case "close"
          theVerb = WebPartZone1.CloseVerb
        Case "export"
          theVerb = WebPartZone1.ExportVerb
        Case "delete"
          theVerb = WebPartZone1.DeleteVerb
        Case "minimize"
          theVerb = WebPartZone1.MinimizeVerb
        Case "restore"
          theVerb = WebPartZone1.RestoreVerb
        Case Else
          theVerb = Nothing
      End Select

      If item.Selected Then
        theVerb.Enabled = True
      Else
        theVerb.Enabled = False
      End If
    Next item

  End Sub

End Class

コード例のもう 1 つの部分は、コントロールをホストし、 プロパティのHelpVerb使用方法をTextDisplayWebPart示す .aspx ページです。 ページの上部付近では、 <@ Register %> コンパイルされたコントロールを参照するために宣言が使用されます TextDisplayWebPart 。これは Bin という名前のサブフォルダーに配置する必要があります。

<%@ Page Language="C#" 
  Codefile="webpartzonebase_verbs.cs"
  Inherits="WebPartZoneBase_verbs"  %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" 
  Assembly="TextDisplayWebPartCS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebPartZoneBase Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="WebPartManager1" Runat="server" />
      <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" />
      <asp:WebPartZone ID="WebPartZone1" Runat="server">
        <CloseVerb Text="Close WebPart" />
        <HelpVerb Text="View Help" />
        <ExportVerb Text="Export WebPart Definition" />
        <DeleteVerb Text ="Delete WebPart" />
        <MinimizeVerb Description="Minimize the control" />
        <RestoreVerb Description="Restore the control" />
        <ZoneTemplate>
        </ZoneTemplate>  
      </asp:WebPartZone>
      <asp:CatalogZone ID="CatalogZone1" Runat="server">
        <ZoneTemplate>
          <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
            Runat="server">
            <WebPartsTemplate>
              <aspSample:TextDisplayWebPart 
                runat="server"   
                id="textwebpart" 
                title = "Text Content WebPart" 
                width="350px" 
                AllowClose="true"
                ExportMode="All"
                HelpMode="Modal"
                HelpUrl="TextWebPartHelp.htm" />            
            </WebPartsTemplate>
          </asp:DeclarativeCatalogPart> 
          <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
        </ZoneTemplate>
      </asp:CatalogZone>
      <asp:Table ID="Table1" Runat="server">
        <asp:TableRow>
          <asp:TableCell>
            <asp:CheckBoxList ID="CheckBoxList1" Runat="server" 
              AutoPostBack="true" 
              OnSelectedIndexChanged="CheckBoxList1_SelectedItemIndexChanged">
              <asp:ListItem Value="close">Close Verb Enabled</asp:ListItem>
              <asp:ListItem Value="delete">Delete Verb Enabled</asp:ListItem>
              <asp:ListItem Value="export">Export Verb Enabled</asp:ListItem>
              <asp:ListItem Value="minimize">Minimize Verb Enabled</asp:ListItem>
              <asp:ListItem Value="restore">Restore Verb Enabled</asp:ListItem>
            </asp:CheckBoxList>
          </asp:TableCell>
        </asp:TableRow>
      </asp:Table>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" 
  Codefile="webpartzonebase_verbs.vb"
  Inherits="WebPartZoneBase_verbs"  %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls" 
  Assembly="TextDisplayWebPartVB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebPartZoneBase Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="WebPartManager1" Runat="server" />
      <uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" />
      <asp:WebPartZone ID="WebPartZone1" Runat="server">
        <CloseVerb Text="Close WebPart" />
        <HelpVerb Text="View Help" />
        <ExportVerb Text="Export WebPart Definition" />
        <DeleteVerb Text ="Delete WebPart" />
        <MinimizeVerb Description="Minimize the control" />
        <RestoreVerb Description="Restore the control" />
        <ZoneTemplate>
        </ZoneTemplate>  
      </asp:WebPartZone>
      <asp:CatalogZone ID="CatalogZone1" Runat="server">
        <ZoneTemplate>
          <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
            Runat="server">
            <WebPartsTemplate>
              <aspSample:TextDisplayWebPart 
                runat="server"   
                id="textwebpart" 
                title = "Text Content WebPart" 
                width="350px" 
                AllowClose="true"
                ExportMode="All"
                HelpMode="Modal"
                HelpUrl="TextWebPartHelp.htm" />            
            </WebPartsTemplate>
          </asp:DeclarativeCatalogPart> 
          <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
        </ZoneTemplate>
      </asp:CatalogZone>
      <asp:Table ID="Table1" Runat="server">
        <asp:TableRow>
          <asp:TableCell>
            <asp:CheckBoxList ID="CheckBoxList1" Runat="server" 
              AutoPostBack="true" 
              OnSelectedIndexChanged="CheckBoxList1_SelectedItemIndexChanged">
              <asp:ListItem Value="close">Close Verb Enabled</asp:ListItem>
              <asp:ListItem Value="delete">Delete Verb Enabled</asp:ListItem>
              <asp:ListItem Value="export">Export Verb Enabled</asp:ListItem>
              <asp:ListItem Value="minimize">Minimize Verb Enabled</asp:ListItem>
              <asp:ListItem Value="restore">Restore Verb Enabled</asp:ListItem>
            </asp:CheckBoxList>
          </asp:TableCell>
        </asp:TableRow>
      </asp:Table>
    </div>
    </form>
</body>
</html>

また、次の HelpVerb コード例に <asp:WebPartZone> 示すように、 プロパティは、動詞のテキストを設定するために 要素で宣言的に使用されることに注意してください。

<asp:WebPartZone ID="WebPartZone1" Runat="server">
  <CloseVerb Text="Close WebPart" />
  <HelpVerb Text="View Help" />
  <ExportVerb Text="Export WebPart Definition" />
  <DeleteVerb Text ="Delete WebPart" />
  <MinimizeVerb Description="Minimize the control" />
  <RestoreVerb Description="Restore the control" />
  <ZoneTemplate>
  </ZoneTemplate>  
</asp:WebPartZone>
<asp:WebPartZone ID="WebPartZone1" Runat="server">
  <CloseVerb Text="Close WebPart" />
  <HelpVerb Text="View Help" />
  <ExportVerb Text="Export WebPart Definition" />
  <DeleteVerb Text ="Delete WebPart" />
  <MinimizeVerb Description="Minimize the control" />
  <RestoreVerb Description="Restore the control" />
  <ZoneTemplate>
  </ZoneTemplate>  
</asp:WebPartZone>

最後に、次のコード例では、 HelpUrl プロパティが ヘルプ ファイルの URL を提供するように 要素に <aspSample:TextDisplayPart> 設定されていることに注意してください。

<asp:CatalogZone ID="CatalogZone1" Runat="server">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      Runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          width="350px" 
          AllowClose="true"
          ExportMode="All"
          HelpMode="Modal"
          HelpUrl="TextWebPartHelp.htm" />            
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
  </ZoneTemplate>
</asp:CatalogZone>
<asp:CatalogZone ID="CatalogZone1" Runat="server">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      Runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          width="350px" 
          AllowClose="true"
          ExportMode="All"
          HelpMode="Modal"
          HelpUrl="TextWebPartHelp.htm" />            
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
  </ZoneTemplate>
</asp:CatalogZone>

ブラウザーでページを読み込んだ後、表示モード ドロップダウン リスト コントロールの [カタログ モード] メニュー項目をクリックして、ページをカタログ表示モードに切り替えます。 コントロールを TextDisplayWebPart ページに追加し、カタログを閉じて、ページを通常のブラウズ モードに戻します。 コントロールのタイトル バー TextDisplayWebPart で [動詞] ドロップダウン メニューをクリックすると、ヘルプ動詞にアクセスして [ヘルプ] ページを開くことができます。

注釈

プロパティには HelpVerb 、宣言型またはプログラムによってアクセスできます。 ゾーン内で宣言によってアクセスするには、 要素を <asp:HelpVerb> 使用してテキスト、説明、動詞が有効になっているかどうか、およびその他の属性を設定します。 ただし、既定で有効になっているため、ゾーンのヘルプ動詞を宣言する必要はありません。 実行時に、ヘルプ動詞をゾーン内のコントロールの動詞メニューに表示できるようにするために必要な唯一の手順は、個々WebPartWebPartコントロールの プロパティに値をHelpUrl割り当てることです。

適用対象

こちらもご覧ください