Share via


LimitedWebPartManager.ImportWebPart method

Imports a Web Part from a string in the .dwp format.

Namespace:  Microsoft.SharePoint.Client.WebParts
Assembly:  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
Public Function ImportWebPart ( _
    webPartXml As String _
) As WebPartDefinition
'Usage
Dim instance As LimitedWebPartManager
Dim webPartXml As String
Dim returnValue As WebPartDefinition

returnValue = instance.ImportWebPart(webPartXml)
public WebPartDefinition ImportWebPart(
    string webPartXml
)

Parameters

Return value

Type: Microsoft.SharePoint.Client.WebParts.WebPartDefinition
Returns a WebPartDefinition instance representing the Web Part markup to import.

Exceptions

Exception Condition
[Microsoft.SharePoint.WebPartPages.WebPartPageUserException]

The provided Web Part markup is not in the .dwp or .webpart format. Error code: -1

[System.UnauthorizedAccessException]

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

Remarks

After importing, the Web Part is not added to a Web Part Page. To add a Web Part to a Web Part Page, use AddWebPart, supplying the object returned by this method.

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: AddWebPart.

It must not be a null reference (Nothing in Visual Basic). It must not be empty. It must be valid XML in the .dwp or .webpart format.

Schema

<s:schema targetNamespace="https://schemas.microsoft.com/WebPart/v2" xmlns:wpv2="https://schemas.microsoft.com/WebPart/v2" elementFormDefault="qualified">
   <s:element name="WebPart">
      <s:complexType>
         <s:sequence minOccurs="2" maxOccurs="unbounded">
            <s:any namespace="##any" minOccurs="0" maxOccurs="unbounded" />
         </s:sequence>
         <s:attribute name="ID" type="s:string" use="optional" />
         <s:anyAttribute namespace="##any"/>
      </s:complexType>
   </s:element>
</s:schema>

Schema

<s:schema elementFormDefault="qualified">
   <s:element name="XML">
      <s:complexType>
         <s:sequence>
            <s:element name="ConnDesign">
               <s:complexType>
                  <s:sequence>
                     <s:element name="ConnectionInfo">
                        <s:complexType>
                           <s:sequence>
                              <s:element name="WebPart" minOccurs="0" maxOccurs="unbounded">
                                 <s:complexType>
                                    <s:sequence>
                                       <s:element name="InterfaceGroups" minOccurs="1" maxOccurs="1">
                                          <s:complexType>
                                             <s:sequence>
                                                <s:element name="InterfaceGroup" minOccurs="0" maxOccurs="unbounded">
                                                   <s:complexType>
                                                      <s:sequence>
                                                         <s:element name="Interfaces">
                                                            <s:complexType>
                                                               <s:sequence>
                                                                  <s:element name="Interface">
                                                                     <s:complexType>
                                                                        <s:choice minOccurs="0" maxOccurs="1">
                                                                           <s:element name="InitEventArgs" type="InitEventArgsType"/>
                                                                           <s:element name="Properties" type="PropertiesType" />
                                                                        </s:choice>
                                                                        <s:attribute name="IsASP" type="s:string" />
                                                                        <s:attribute name="Match" type="s:string" />
                                                                        <s:attribute name="InterfaceName" type="s:string" />
                                                                        <s:attribute name="Type" type="s:string" />
                                                                        <s:attribute name="MenuLabel" type="s:string" />
                                                                        <s:attribute name="Description" type="s:string" />
                                                                     </s:complexType>
                                                                  </s:element>
                                                               </s:sequence>
                                                            </s:complexType>
                                                         </s:element>
                                                      </s:sequence>
                                                      <s:attribute name="GroupName" type="s:string" use="required" />
                                                      <s:attribute name="GroupMenuLabel" type="s:string" use="required" />
                                                      <s:attribute name="IsASP" type="s:string" use="required" />
                                                      <s:attribute name="Description" type="s:string" use="required" />
                                                      <s:attribute name="RunAt" type="runAtType" use="required" />
                                                      <s:attribute name="MaxConnections" use="required">
                                                         <s:simpleType>
                                                            <s:restriction base="s:integer">
                                                               <s:enumeration value="-1" />
                                                               <s:enumeration value="1" />
                                                            </s:restriction>
                                                         </s:simpleType>
                                                      </s:attribute>
                                                      <s:attribute name="AllowCrossPageConnection" type="s:string" use="required" />
                                                      <s:attribute name="ConnectionType" type="ConnectionTypeType" use="required" />
                                                   </s:complexType>
                                                </s:element>
                                             </s:sequence>
                                          </s:complexType>
                                       </s:element>
                                    </s:sequence>
                                    <s:attribute name="ID" type="s:string" />
                                    <s:attribute name="WebPartID" type="s1:guid" />
                                    <s:attribute name="ConnectionID" type="s1:guid" />
                                 </s:complexType>
                              </s:element>
                           </s:sequence>
                        </s:complexType>
                     </s:element>
                     <s:element name="Compatibility">
                        <s:complexType>
                           <s:sequence>
                              <s:element name="sWebPart" minOccurs="0" maxOccurs="1">
                                 <s:complexType>
                                    <s:sequence>
                                       <s:element name="sInterfaces">
                                          <s:complexType>
                                             <s:sequence>
                                                <s:element name="int" minOccurs="0" maxOccurs="unbounded">
                                                   <s:complexType>
                                                      <s:choice minOccurs="0" maxOccurs="1">
                                                         <s:element name="InitEventArgs" type="InitEventArgsType"/>
                                                         <s:element name="Properties" type="PropertiesType" />
                                                      </s:choice>
                                                      <s:attribute name="IsASP" type="s:string" />
                                                      <s:attribute name="id" type="s:string" />
                                                   </s:complexType>
                                                </s:element>
                                             </s:sequence>
                                          </s:complexType>
                                       </s:element>
                                       <s:element name="sg" minOccurs="0" maxOccurs="unbounded">
                                          <s:complexType>
                                             <s:sequence>
                                                <s:element name="tParts">
                                                   <s:complexType>
                                                      <s:sequence>
                                                         <s:element name="tWebPart" minOccurs="0" maxOccurs="unbounded">
                                                            <s:complexType>
                                                               <s:sequence>
                                                                  <s:element name="tg" minOccurs="0" maxOccurs="unbounded">
                                                                     <s:complexType>
                                                                        <s:sequence>
                                                                           <s:element name="tInterface">
                                                                              <s:complexType>
                                                                                 <s:sequence>
                                                                                    <s:choice minOccurs="0" maxOccurs="1">
                                                                                       <s:element name="InitEventArgs" type="InitEventArgsType"/>
                                                                                       <s:element name="Properties" type="PropertiesType" />
                                                                                    </s:choice>
                                                                                    <s:element name="mi" minOccurs="1" maxOccurs="1">
                                                                                       <s:complexType>
                                                                                          <s:sequence />
                                                                                          <s:attribute name="xInfo" type="s:string" />
                                                                                          <s:attribute name="id" type="s:string" />
                                                                                          <s:attribute name="isXFormUINeeded" type="s:string" />
                                                                                       </s:complexType>
                                                                                    </s:element>
                                                                                    <s:element name="xForm" minOccurs="0" maxOccurs="1">
                                                                                       <s:complexType>
                                                                                          <s:sequence />
                                                                                          <s:attribute name="type" type="s:string" />
                                                                                       </s:complexType>
                                                                                    </s:element>
                                                                                 </s:sequence>
                                                                                 <s:attribute name="IsASP" type="s:string" />
                                                                                 <s:attribute name="id" type="s:string" />
                                                                              </s:complexType>
                                                                           </s:element>
                                                                        </s:sequence>
                                                                        <s:attribute name="id" type="s:string" />
                                                                        <s:attribute name="gLabel" type="s:string" />
                                                                        <s:attribute name="des" type="s:string" />
                                                                        <s:attribute name="isMaxedOut" type="s:string" />
                                                                        <s:attribute name="runAt" type="runAtType">
                                                                        </s:attribute>
                                                                        <s:attribute name="ConnectionType" type="ConnectionTypeType">
                                                                        </s:attribute>
                                                                        <s:attribute name="IsASP" type="s:string" />
                                                                        <s:attribute name="isConn" type="s:string" />
                                                                     </s:complexType>
                                                                  </s:element>
                                                               </s:sequence>
                                                               <s:attribute name="ID" type="s:string" use="required" />
                                                               <s:attribute name="WebPartID" type="s:string" use="optional" />
                                                               <s:attribute name="ConnectionID" type="s:string" use="optional" />
                                                               <s:attribute name="pinnedTo" type="runAtType" />
                                                               <s:attribute name="title" type="s:string" use="required" />
                                                            </s:complexType>
                                                         </s:element>
                                                      </s:sequence>
                                                   </s:complexType>
                                                </s:element>
                                             </s:sequence>
                                             <s:attribute name="des" type="s:string" use="required" />
                                             <s:attribute name="isMaxedOut" type="s:string" />
                                             <s:attribute name="id" type="s:string" use="required" />
                                             <s:attribute name="ConnectionType" type="ConnectionTypeType" use="required" />
                                             <s:attribute name="IsASP" type="s:string" />
                                             <s:attribute name="runAt" type="runAtType" use="required" />
                                             <s:attribute name="gLabel" type="s:string" use="required" />
                                          </s:complexType>
                                       </s:element>
                                    </s:sequence>
                                    <s:attribute name="ID" type="s:string" use="required" />
                                    <s:attribute name="pinnedTo" type="runAtType" use="optional" />
                                    <s:attribute name="WebPartID" type="s:string" use="optional" />
                                    <s:attribute name="ConnectionID" type="s:string" use="optional" />
                                    <s:attribute name="title" type="s:string" />
                                 </s:complexType>
                              </s:element>
                           </s:sequence>
                        </s:complexType>
                     </s:element>
                  </s:sequence>
               </s:complexType>
            </s:element>
         </s:sequence>
         <s:attribute name="id" use="optional">
            <s:simpleType>
               <s:restriction base="s:string">
                  <s:enumeration value="MSOConn_Compatibility" />
               </s:restriction>
            </s:simpleType>
         </s:attribute>
      </s:complexType>
   </s:element>
</s:schema>

See also

Reference

LimitedWebPartManager class

LimitedWebPartManager members

Microsoft.SharePoint.Client.WebParts namespace