Imports an XML description file that contains state and property data for a WebPart control, and applies the data to the control.
Assembly: System.Web (in System.Web.dll)
- Type: System.Xml.XmlReader
An XmlReader that reads the state and property data from the XML description file that is being imported.
The 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 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 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.