Export (0) Print
Expand All

ToolPane Class

Represents the tool pane on a Web Part Page. This class cannot be inherited.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ToolPane : EditorZoneBase, 
	INamingContainer

The following example demonstrates the use of the ToolPane class and the three methods of the ICustomizeToolPane interface in a simple Web Part. The RenderWebPart method uses the GetShowExtensibleToolPaneEvent to associate a button control on the Web Part with the JavaScript required to open the extensible tool pane. The ToolPaneTemplate property provides the layout of the tool pane, while the CreateToolPaneControls method draws the tool pane's controls.

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft