다음을 통해 공유


LimitedWebPartManager.AddWebPart Method

Adds a Web Part to the Web Part Page.

Namespace:  Microsoft.SharePoint.Client.WebParts
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
<RemoteAttribute> _
Public Function AddWebPart ( _
    webPart As WebPart, _
    zoneId As String, _
    zoneIndex As Integer _
) As WebPartDefinition
'Usage
Dim instance As LimitedWebPartManager
Dim webPart As WebPart
Dim zoneId As String
Dim zoneIndex As Integer
Dim returnValue As WebPartDefinition

returnValue = instance.AddWebPart(webPart, _
    zoneId, zoneIndex)
[RemoteAttribute]
public WebPartDefinition AddWebPart(
    WebPart webPart,
    string zoneId,
    int zoneIndex
)

Parameters

  • zoneId
    Type: System.String

    The name of the Web Part zone to which to add the Web Part.

  • zoneIndex
    Type: System.Int32

    A Web Part zone index that specifies the position at which the Web Part will be inserted within the Web Part zone.

Return Value

Type: Microsoft.SharePoint.Client.WebParts.WebPartDefinition
Returns a WebPartDefinition instance representing the position at which the Web Part will be inserted within the Web Part zone.

Exceptions

Exception Condition
[System.UnauthorizedAccessException]

The current user has insufficient permissions. Error code: -2147024891

Remarks

When Scope is User, the current user must have permissions to add and delete personalized Web Parts. When Scope is Shared, the current user must have permissions to customize pages. See also: ImportWebPart, in the following section. Use ImportWebPart to import a Web Part, and then use AddWebPart to add it to the Web Part Page. Each Web Part zone must have a unique name. It must not be a null reference (Nothing in Visual Basic). It must not be empty. Its length must be equal to or less than 64.

The new Web Part must be inserted directly before the existing Web Part with the lowest Web Part zone index greater than or equal to zoneIndex. If zoneIndex is greater than the index of all Web Parts in the zone or there are no Web Parts in the Web Part zone, then the new Web Part must be inserted at the end of the Web Part zone. Its value must be equal to or greater than 0.

See Also

Reference

LimitedWebPartManager Class

LimitedWebPartManager Members

Microsoft.SharePoint.Client.WebParts Namespace