ToolPane class
表示在 [網頁組件頁面上的 [工具] 窗格。無法繼承這個類別。
Inheritance hierarchy
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
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ToolPane _
Inherits EditorZoneBase _
Implements INamingContainer
'用途
Dim instance As ToolPane
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ToolPane : EditorZoneBase,
INamingContainer
Examples
下列範例會示範使用ToolPane類別和ICustomizeToolPane介面簡單的網頁組件中的三種方法。RenderWebPart方法會使用GetShowExtensibleToolPaneEvent ,在 [網頁組件上的按鈕控制項關聯,才能開啟 「 可延伸的工具窗格 JavaScript。ToolPaneTemplate屬性提供工具窗格中,版面的配置,而CreateToolPaneControls方法會繪製] 工具窗格控制項。
'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";
}
}
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.