SPWebPartManager.ImportWebPart Method
Imports an XML description file that contains state and property data for a Web Part, applies the data to the Web Part, and registers the Web Part with the SPWebPartManager.
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
Public Overrides Function ImportWebPart ( _
reader As XmlReader, _
<OutAttribute> ByRef errorMessage As String _
) As WebPart
'Usage
Dim instance As SPWebPartManager
Dim reader As XmlReader
Dim errorMessage As String
Dim returnValue As WebPart
returnValue = instance.ImportWebPart(reader, _
errorMessage)
public override WebPart ImportWebPart(
XmlReader reader,
out string errorMessage
)
Parameters
reader
Type: System.Xml.XmlReaderAn XmlReader that reads the state and property data from the XML description file that is being imported.
errorMessage
Type: System.StringA string that is displayed to the user if an error is encountered during import.
Return Value
Type: System.Web.UI.WebControls.WebParts.WebPart
The imported Web Part that is referenced in the XML description file.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | reader is a null reference (Nothing in Visual Basic). |
Remarks
This override does not import the actual Web Part control. The XML description file contains only state and property data about the Web Part. The control and assembly referenced in the description file must already be available on the server.