WebPartManager.ExportSensitiveDataWarning Property


Gets or sets the text of a warning message that is displayed when a user attempts to export sensitive state data from a WebPart control.

Namespace:   System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

public virtual string ExportSensitiveDataWarning { get; set; }

Property Value

Type: System.String

A string that contains the warning message. The default message is a culture-specific value supplied by the .NET Framework.

When a user attempts to export sensitive state data from a WebPart control, if any of the data being exported comes from a member that was marked as sensitive in the source code, a warning message is displayed to the user in a message box, telling them that sensitive data is being exported and providing an opportunity to cancel the export. Developers can mark a specific member's data as sensitive by setting the isSensitive parameter of the [Personalizable] attribute to true on the member. For more information about this attribute and parameter, see the PersonalizableAttribute class.

System_CAPS_security Security Note

When you use the export feature of Web Parts, sensitive data could potentially be exported to unauthorized users. For details on how to protect against this threat, see Securing Web Parts Pages.

The default message is displayed whenever users attempt to export. However, by assigning a value to the ExportSensitiveDataWarning property, you can provide a custom warning message.

The following code example demonstrates the declarative use of the ExportSensitiveDataWarning property.

The code for the following Web page uses a standard BulletedList control and places it in a zone. The control will be wrapped with a GenericWebPart control at run time, which enables it to act as a true WebPart control. To make the control exportable, an ExportMode attribute is added to the <asp:bulletedlist> element, and the attribute value is set to All, which means that both sensitive and non-sensitive data can be exported. Note also that in the <asp:webpartmanager> element, the ExportSensitiveDataWarning attribute is assigned a custom value.

Note that for the code example to work, there is a setting you must add in the Web.config file to enable exporting Web Parts description files. Ensure that you have a Web.config file in the same directory as the Web page for this code example. Within the <system.web> section, make sure there is a <webParts> element with an enableExport attribute set to true, as in the following markup.

<webParts enableExport="true">



<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
    <form id="form1" runat="server">
      <asp:WebPartManager ID="WebPartManager1" 
        ExportSensitiveDataWarning="Sensitive data is being exported"/>
      <asp:WebPartZone ID="WebPartZone1" runat="server">
            Title="My Links"
            <asp:ListItem Value="http://www.microsoft.com">
            <asp:ListItem Value="http://www.msn.com">
            <asp:ListItem Value="http://www.contoso.com">
            Contoso Corp.

After you load the page in a browser, click the verbs menu (represented by a downward arrow) in the title bar of the control that contains the links. In the verbs menu, select Export, and notice that a message box appears with the custom warning. If you want to continue with the export, click OK, which will allow you to save a local copy of an XML description file with all the data about the control.

.NET Framework
Available since 2.0
Return to top