This topic has not yet been rated - Rate this topic

WebPartGalleryPicker Class

NOTE: This API is now obsolete.

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.WebPartGalleryPicker

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[ObsoleteAttribute("Functionality has been superceded by the WebPartAdder class.")]
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
public sealed class WebPartGalleryPicker : Control
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
WebPartGalleryPicker
Description

The Microsoft.SharePoint.WebControls.WebPartGalleryPicker inherits from the System.Web.UI.Control base class in order to define a new server control. Within the shipped software, the WebPartGalleryPicker is immediately apparent when you are adding a new WebPart to a WebPartPage, characterized by the popup dialog that conditionally presents available WebParts. 

The class relies on two separate WebPart containment hierarchy objects, WebPartInfo and and WebPartData. The WebPartData class is an internal class which allow representation of structural information regarding the WebPart such as assembly, culture, and type name. WebPartInfo provides more ascetic concepts such as the WebPart group, title, and description. Each of these object is used to conditionally display the appropriate WebParts and their respective information. 

When creating a new WebPartGalleyPicker, in the object constructor there are three parameters demanded, a string array for the related groups, a Boolean value to determine whether lists and libraries should be displayed, and a string that represents the zone name. 

Usage Scenario

The primary use of WebPartGalleyPicker is internal due to such heavy representation within the shipped software. However, since it is a standard control it is possible to slightly manipulate the dialog box or extend it while inclusive in other controls. In the below, I am demonstrating creating a new WebPartGalleryPicker object and satisfying the conditions of its constructor with some delcrative values. Following, I am adding the object to the current instance control collection.

C# Code Example

protected override void CreateChildControls()
{
string [] myGroups = new string[] {"Group1", "Group2"};
WebPartGalleryPicker picker = new WebPartGalleryPicker(myGroups, true, "Master Zone");
Controls.Add(picker);
base.CreateChildControls();
}

Visual Basic .NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
Dim myGroups As String() = New String() {"Group1", "Group2"}
Dim picker As New WebPartGalleryPicker(myGroups, True, "Master Zone")
Controls.Add(picker)
MyBase.CreateChildControls()
End Sub

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com