Assembly: System.Web (in system.web.dll)
public WebPart ImportWebPart ( XmlReader reader, /** @attribute OutAttribute() */ /** @ref */ String errorMessage )
An XmlReader that reads the state and property data from the XML description file that is being imported.
A String that is displayed to the user if an error is encountered during import.
Return ValueA WebPart (or a server control that is wrapped by a GenericWebPart and thus treated as a WebPart) that is referenced in the imported XML description file.
reader is a null reference (Nothing in Visual Basic).
reader could not read the file.
- or -
reader needed to display an import error message but did not find one in the file.
- or -
reader reached the end of the file without finding the XML element that contains the exported data.
The ImportWebPart method imports an XML description file that was created by the ExportWebPart method for a server control. It is not the actual server control that is imported, but only the description file containing state and property data about the control. The control and assembly referenced in the description file must already be available on the server where a user attempts to import the description file.
To enable importing a control, a developer needs to add a CatalogZone control on the page where import will be enabled. Within the zone, an ImportCatalogPart control must be added. This control provides a file dialog box that allows users to browse and locate the description file to import.
After a user finds a description file and begins the import, the description file is read by the ImportWebPart method. If there are no errors and if the assembly and control are found, the server control is added to the catalog within the ImportCatalogPart control, and the various property and state data specified in the description file are applied to the control. The user can then select the control and add it to the page.
Like the ExportWebPart method, the ImportWebPart method has some potential for security risks. Because it involves importing data into a Web site, a malicious user could try to insert bad data or even script code into the description file that is imported. Then the bad data could appear on a page, or in a database, or the inserted script could run. For an overview of the potential risks associated with importing description files, and ways of avoiding those risks, see Securing Web Parts Pages.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.