WebPartManager.ExportSensitiveDataWarning 属性
定义
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
属性值
一个包含警告消息的字符串。A string that contains the warning message. 默认消息是由 .NET Framework 提供的、特定于区域性的值。The default message is a culture-specific value supplied by the .NET Framework.
示例
下面的代码示例演示了属性的声明性用法 ExportSensitiveDataWarning 。The following code example demonstrates the declarative use of the ExportSensitiveDataWarning property.
以下网页的代码使用标准 BulletedList 控件,并将其放在区域中。The code for the following Web page uses a standard BulletedList control and places it in a zone. 控件将 GenericWebPart 在运行时与控件一起包装,这样它就可以作为真正的 WebPart 控件。The control will be wrapped with a GenericWebPart control at run time, which enables it to act as a true WebPart control. 若要使控件可导出,请将 ExportMode 属性添加到 <asp:bulletedlist> 元素,并将属性值设置为 All ,这意味着可以导出敏感数据和非敏感数据。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. 另请注意,在 <asp:webpartmanager> 元素中, ExportSensitiveDataWarning 为属性分配自定义值。Note also that in the <asp:webpartmanager> element, the ExportSensitiveDataWarning attribute is assigned a custom value.
请注意,若要使代码示例正常运行,必须在 Web.config 文件中添加一个设置,以便导出 Web 部件说明文件。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. 请确保在此代码示例的网页所在的同一目录中有一个 Web.config 文件。Ensure that you have a Web.config file in the same directory as the Web page for this code example. 在 <system.web> 部分中,请确保有一个 <webParts> 元素的 enableExport 属性设置为 true ,如以下标记所示。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. 如果要继续导出,请单击 "确定",这将允许你使用有关控件的所有数据保存 XML 说明文件的本地副本。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.
注解
当用户尝试从控件中导出敏感状态数据时 WebPart ,如果导出的任何数据来自源代码中标记为 "敏感" 的成员,则会在消息框中向用户显示一条警告消息,告诉他们正在导出敏感数据,并提供取消导出的机会。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. 开发人员可以通过 isSensitive [Personalizable] 在成员上将属性的参数设置为来将特定成员的数据标记为敏感数据 true 。Developers can mark a specific member's data as sensitive by setting the isSensitive parameter of the [Personalizable] attribute to true on the member. 有关此特性和参数的详细信息,请参阅 PersonalizableAttribute 类。For more information about this attribute and parameter, see the PersonalizableAttribute class.
重要
使用 Web 部件的导出功能时,敏感数据可能会导出到未经授权的用户。When you use the export feature of Web Parts, sensitive data could potentially be exported to unauthorized users. 有关如何防范此威胁的详细信息,请参阅 保护 Web 部件页面。For details on how to protect against this threat, see Securing Web Parts Pages.
每当用户尝试导出时,都会显示默认消息。The default message is displayed whenever users attempt to export. 但是,通过将值分配给 ExportSensitiveDataWarning 属性,可以提供自定义警告消息。However, by assigning a value to the ExportSensitiveDataWarning property, you can provide a custom warning message.