Bewerken

Delen via


WebPartManager.ExportSensitiveDataWarning Property

Definition

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.

public:
 virtual property System::String ^ ExportSensitiveDataWarning { System::String ^ get(); void set(System::String ^ value); };
public virtual string ExportSensitiveDataWarning { get; set; }
member this.ExportSensitiveDataWarning : string with get, set
Public Overridable Property ExportSensitiveDataWarning As String

Property Value

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

Examples

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">

...

</webParts>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="WebPartManager1" 
        runat="server" 
        ExportSensitiveDataWarning="Sensitive data is being exported"/>
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:BulletedList 
            DisplayMode="HyperLink" 
            ID="BulletedList1" 
            runat="server"
            Title="My Links"
            ExportMode="All">
            <asp:ListItem Value="http://www.microsoft.com">
            Microsoft
            </asp:ListItem>
            <asp:ListItem Value="http://www.msn.com">
            MSN
            </asp:ListItem>
            <asp:ListItem Value="http://www.contoso.com">
            Contoso Corp.
            </asp:ListItem>
          </asp:BulletedList> 
        </ZoneTemplate>
      </asp:WebPartZone>
      </div>
     </form>
</body>
</html>
<%@ Page Language="vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="WebPartManager1" runat="server" />
      <asp:WebPartManager ID="WebPartManager2" 
        runat="server" 
        ExportSensitiveDataWarning="Sensitive data is being exported"/>
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:BulletedList 
            DisplayMode="HyperLink" 
            ID="BulletedList1" 
            runat="server"
            Title="My Links"
            ExportMode="All">
            <asp:ListItem Value="http://www.microsoft.com">
            Microsoft
            </asp:ListItem>
            <asp:ListItem Value="http://www.msn.com">
            MSN
            </asp:ListItem>
            <asp:ListItem Value="http://www.contoso.com">
            Contoso Corp.
            </asp:ListItem>
          </asp:BulletedList> 
        </ZoneTemplate>
      </asp:WebPartZone>
      </div>
     </form>
</body>
</html>

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.

Remarks

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.

Important

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.

Applies to

See also