|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
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 thecontrol. 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.
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.
To enable importing on a page
Create an ASP.NET Web Parts page that includes azone that in turn contains an ImportCatalogPart control inside a 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>
The page must contain acontrol for Web Parts controls to function. For more information, see .
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, seeand .
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.