Compartir a través de


Clase ToolPane

Representa el panel de herramientas en una página de elementos Web. Esta clase no se puede heredar.

Jerarquía de la herencia

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

Espacio de nombres:  Microsoft.SharePoint.WebPartPages
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

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

Ejemplos

En el siguiente ejemplo se muestra el uso de la clase ToolPane y los tres métodos de la interfaz de ICustomizeToolPane en un elemento Web simple. El método RenderWebPart utiliza el GetShowExtensibleToolPaneEvent para asociar un control de botón en el elemento Web con el código JavaScript requerido para abrir el panel de herramientas extensible. La propiedad ToolPaneTemplate proporciona el diseño del panel de herramientas, mientras que el método CreateToolPaneControls dibuja los controles del panel de herramientas.

'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";
    }
}

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros ToolPane

Espacio de nombres Microsoft.SharePoint.WebPartPages