Partager via


ToolPane - Classe

Représente le volet de l'outil sur une Page de composants WebPart. Cette classe ne peut pas être héritée.

Hiérarchie d’héritage

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      System.Web.UI.WebControls.CompositeControl
        System.Web.UI.WebControls.WebParts.WebZone
          System.Web.UI.WebControls.WebParts.ToolZone
            System.Web.UI.WebControls.WebParts.EditorZoneBase
              Microsoft.SharePoint.WebPartPages.ToolPane

Espace de noms :  Microsoft.SharePoint.WebPartPages
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ToolPane _
    Inherits EditorZoneBase _
    Implements INamingContainer
'Utilisation
Dim instance As ToolPane
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ToolPane : EditorZoneBase, 
    INamingContainer

Exemples

L'exemple suivant illustre l'utilisation de la classe ToolPane et les trois méthodes de l'interface ICustomizeToolPane dans un composant WebPart simple. La méthode RenderWebPart utilise le GetShowExtensibleToolPaneEvent pour associer un contrôle bouton sur le composant WebPart avec le code JavaScript nécessaire pour ouvrir le volet d'outils extensibles. La propriété ToolPaneTemplate fournit la mise en page du volet d'outils, tandis que la méthode CreateToolPaneControls dessine des contrôles du volet d'outils.

'The custom WebPart class
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages

<ToolboxData("<{0}:WPToolPaneTest runat=server></{0}:WPToolPaneTest>"), _
XmlRoot(Namespace:="WPToolPaneTest")> _
 Public Class WPToolPaneTest
    Inherits Microsoft.SharePoint.WebPartPages.WebPart
    Implements ICustomizeToolPane

    Public Sub New()
    End Sub

    Protected Overrides Sub RenderWebPart(ByVal output As 
    System.Web.UI.HtmlTextWriter)
        output.Write("Web Part with an extensible tool pane.<br><br>")
        output.Write("<input type=""button"" class=""ms-SPButton"" 
            value=""Show Extensible ToolPane"" ")
        output.Write("onclick=""" & ToolPane.
            GetShowExtensibleToolPaneEvent("'" & Me.UniqueID & "'"))
        output.Write("""/><br><br>")
    End Sub

    Public Sub CreateToolPaneControls(ByVal toolpane As 
    Microsoft.SharePoint.WebPartPages.ToolPane) _
    Implements Microsoft.SharePoint.WebPartPages.ICustomizeToolPane.
        CreateToolPaneControls
        ' Display a custom tool part followed by the standard properties
        Dim myToolPart As TPToolPaneTest = New TPToolPaneTest
        toolpane.InsertToolPart(0, myToolPart)
        Dim standardToolPart As WebPartToolPart = New WebPartToolPart
        toolpane.InsertToolPart(1, standardToolPart)
    End Sub

    Public Function ShowZoneIdentification() As Boolean _
    Implements Microsoft.SharePoint.WebPartPages.ICustomizeToolPane.
            ShowZoneIdentification
        Return True
    End Function

    Public ReadOnly Property ToolPaneTemplate() As String _
    Implements Microsoft.SharePoint.WebPartPages.ICustomizeToolPane.
            ToolPaneTemplate
        Get
            Dim myTemplate As String
            myTemplate = "<?xml version=""1.0""?>"
            myTemplate &= "<ToolPane>"
            myTemplate &= "<Caption title=""Test Toolpane"" 
                name=""Test Toolpane""></Caption>"
            myTemplate &= "<ToolBar></ToolBar>"
            myTemplate &= "<ErrorUI></ErrorUI>"
            myTemplate &= "<FixedArea></FixedArea>"
            myTemplate &= "<NotifyUI></NotifyUI>"
            myTemplate &= "<ToolParts></ToolParts>"
            myTemplate &= "<Commands ok=""true"" cancel=""true"" 
                apply=""true""></Commands>"
            myTemplate &= "</ToolPane>"
            Console.WriteLine(myTemplate)
            Return myTemplate
        End Get
    End Property
End Class
'The custom ToolPart class
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebPartPages

Public Class TPToolPaneTest
    Inherits Microsoft.SharePoint.WebPartPages.ToolPart

    Sub New()
    End Sub

    Protected Overrides Sub RenderToolPart(ByVal output As 
    System.Web.UI.HtmlTextWriter)
        output.RenderBeginTag(HtmlTextWriterTag.Div)
        output.Write("Properties are displayed here for editing.")
        output.RenderEndTag()
    End Sub

    Private Sub TPToolPaneTest_Init(ByVal sender As Object, ByVal e As 
    System.EventArgs) Handles MyBase.Init
        Me.Title = "TPToolPaneTest"
    End Sub

End Class
//The custom WebPart class
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;

[ToolboxData("<{0}:WPToolPaneTest runat=server></{0}:WPToolPaneTest>"), 
    XmlRoot(Namespace="WPToolPaneTest")]
 public class WPToolPaneTest:
    Microsoft.SharePoint.WebPartPages.WebPart,
    ICustomizeToolPane

 {
    public WPToolPaneTest()
    {
    }

    protected override void RenderWebPart(System.Web.UI.HtmlTextWriter output)
    {
        output.Write("Web Part with an extensible tool pane.<br><br>");
        output.Write("<input type=\"button\" class=\"ms-SPButton\" 
            value=\"Show Extensible ToolPane\" ");
        output.Write("onclick=\""+ToolPane.
            GetShowExtensibleToolPaneEvent("'"+this.UniqueID+"'"));
        output.Write("\"/><br><br>");
    }

    public void CreateToolPaneControls(Microsoft.SharePoint.
        WebPartPages.ToolPane toolpane)
    {
        // Display a custom tool part followed by the standard properties
        TPToolPaneTest myToolPart = new TPToolPaneTest;
        toolpane.InsertToolPart(0, myToolPart);
        WebPartToolPart standardToolPart = new WebPartToolPart;
        toolpane.InsertToolPart(1, standardToolPart);
    }

    public bool ShowZoneIdentification()
    {
        return true;
    }

    public string ToolPaneTemplate    
    {
        get
        {
            string myTemplate;
            myTemplate = "<?xml version=\"1.0\"?>";
            myTemplate &= "<ToolPane>";
            myTemplate &= "<Caption title=\"Test Toolpane\" 
                name=\"Test Toolpane\"></Caption>";
            myTemplate &= "<ToolBar></ToolBar>";
            myTemplate &= "<ErrorUI></ErrorUI>";
            myTemplate &= "<FixedArea></FixedArea>";
            myTemplate &= "<NotifyUI></NotifyUI>";
            myTemplate &= "<ToolParts></ToolParts>";
            myTemplate &= "<Commands ok=\"true\" cancel=\"true\" 
                apply=\"true\"></Commands>";
            myTemplate &= "</ToolPane>";
            Console.WriteLine(myTemplate);
            return myTemplate;
        }
    }
 }//The custom ToolPart class
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;



public class TPToolPaneTest:
    Microsoft.SharePoint.WebPartPages.ToolPart
{
    TPToolPaneTest()
    {
        this.Init += new EventHandler(TPToolPaneTest_Init);
    }

    protected overrides void 
        RenderToolPart(System.Web.UI.HtmlTextWriter output)
    {
        output.RenderBeginTag(HtmlTextWriterTag.Div);
        output.Write("Properties are displayed here for editing.");
        output.RenderEndTag();
    }

    private void TPToolPaneTest_Init(object sender, System.EventArgs e)
    {
        this.Title = "TPToolPaneTest";
    }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

ToolPane - Membres

Microsoft.SharePoint.WebPartPages - Espace de noms