Partager via


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

  1. 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.

  2. 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

  1. Open the page in a browser and set the display mode to catalog mode.

  2. Click the Browse button on the ImportCatalogPart control.

  3. Browse to the location of the description file you want to load, select the file, and click Open.

  4. Click the Upload button.

    The control appears inside the ImportCatalogPart control.

  5. 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

ImportCatalogPart

WebPartManager

Other Resources

ASP.NET Web Parts Controls