Editare

Partajați prin


WebPartManager.ExportWebPart(WebPart, XmlWriter) Method

Definition

Creates an XML description file that contains state and property data for a server control.

public:
 virtual void ExportWebPart(System::Web::UI::WebControls::WebParts::WebPart ^ webPart, System::Xml::XmlWriter ^ writer);
public virtual void ExportWebPart (System.Web.UI.WebControls.WebParts.WebPart webPart, System.Xml.XmlWriter writer);
abstract member ExportWebPart : System.Web.UI.WebControls.WebParts.WebPart * System.Xml.XmlWriter -> unit
override this.ExportWebPart : System.Web.UI.WebControls.WebParts.WebPart * System.Xml.XmlWriter -> unit
Public Overridable Sub ExportWebPart (webPart As WebPart, writer As XmlWriter)

Parameters

webPart
WebPart

The control from which data will be exported.

writer
XmlWriter

An XmlWriter that writes the exported data from webPart to an XML description file.

Exceptions

webPart is null.

-or-

writer is null.

webPart is not contained in the collection of controls referenced in Controls.

-or-

The ExportMode property of webPart is set to a value of None, which means that export is disabled for webPart.

Remarks

The ExportWebPart method assembles various state and property data from webPart into an XML file. The data includes information about the control itself, including its assembly, state data, and property data. The user who initiates the export can save the XML file to disk on the local computer or the network. Other users can then import the description file to a different page or Web site, and apply the state and property data to a different instance of webPart. This provides a fast and convenient mechanism for users to share and reuse their settings on server controls, and it also provides developers with a means to control the appearance and behavior of exported and imported controls.

Properties on webPart are not exported by default. To enable export of a property, you must mark it with the [Personalizable] attribute in the source code. You can also optionally mark an exportable property as containing sensitive data, by setting the isSensitive parameter of the [Personalizable] attribute to true. By default, isSensitive is false. Developers can set the parameter to true to indicate that the data is sensitive.

To enable webPart to be exported, a developer sets its ExportMode property value to either All (which includes all personalizable and sensitive properties), or to NonSensitiveData, which exports everything except for sensitive properties.

Important

Allowing users to export data from controls, and to import data into other controls, entails some security risks. Developers should use the approach discussed above to protect sensitive data, and if they want to avoid the risk of exposing data altogether, they should not enable export on webPart at all. For details on Web Parts security issues, see Securing Web Parts Pages.

Applies to

See also