|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. ArchiveDisclaimer|
How to: Export 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. However, before a control can be imported by an end user it must be made available for export by the page developer.
After you have completed the export operation, you will need a way for users to import the control. For more information, see.
To enable a custom Web Parts control for export
Create an ASP.NET page that contains a custom Web Parts control.
This control can be derived from theclass or be any inherited control or user control placed inside a zone. For more information about how to create a Web Parts page, see . For an example of a custom Web Parts control, see WebPart.
Only properties with theattribute are included in the .WebPart file used for export.
In your Web.config file, inside the
<system.web>section, add a
enableExportset to true, as shown in the following example.
Set the ExportMode property of the control to all. If your control is derived fromWebPart, you can do this in markup as shown in the following example.
<aspSample:CustomWebPart id="Sample" runat="server" ExportMode="All" />
If you are not using an inheritedWebPart control but are using another control inside a WebPartZone zone,
you must set theproperty of the containing control in code, as in the example shown in the Example section.
Load the Web page in a browser and, on the verbs menu of the WebPart control, click the export verb and follow the instructions to export a description file that contains the control's state and property data.
To export a control that does not inherit from the WebPart class, you must first place the control inside a WebPartZone zone on the page. This automatically wraps the control in a GenericWebPart control, which you can access through code to set the ExportMode property during the Page_Load() event. In the following example,
Control1 is the name of the control to export.