How to: Enable Users to Import Web Parts Control Settings
Part of the functionality of the Web Parts control set is the ability to import custom Web Parts controls through the use of the ImportCatalogPart control. The ImportCatalogPart control loads a description file, which is an XML file with a .WebPart extension that contains the location and personalizable property values of the control to be imported. When a user clicks the Upload button on the ImportCatalogPart control, the actual control is loaded from the Web server. The user can then add the imported control to the page.
Note
The actual control to be imported must reside on the Web server that hosts the page.
For more information about how to export a description file for importing, see How to: Export Web Parts Control Settings.
To enable importing on a page
Create an ASP.NET Web Parts page that includes a CatalogZone zone that in turn contains an ImportCatalogPart control inside a ZoneTemplate template. The markup for the CatalogZone zone should look something like the following example.
<asp:CatalogZone id="CZ1" runat="server"> <ZoneTemplate> <asp:ImportCatalogPart id="ICP1" runat="server" /> </ZoneTemplate> </asp:CatalogZone>
Note
The page must contain a WebPartManager control for Web Parts controls to function. For more information, see Walkthrough: Creating a Web Parts Page.
Provide a means for the user to switch the page display mode to catalog mode.
For more information on setting and changing page display modes, see How to: Set the Display Mode of a Web Parts Page and Walkthrough: Changing Display Modes on a Web Parts Page.
To import a Web Parts control
Open the page in a browser and set the display mode to catalog mode.
Click the Browse button on the ImportCatalogPart control.
Browse to the location of the description file you want to load, select the file, and click Open.
Click the Upload button.
The control appears inside the ImportCatalogPart control.
Drag the imported control onto the page and set the page display mode back to browse mode.
See Also
Tasks
How to: Export Web Parts Control Settings
How to: Set the Display Mode of a Web Parts Page
Walkthrough: Changing Display Modes on a Web Parts Page
Reference
System.Web.UI.WebControls.WebParts