共用方式為


WebPartManager.ExportSensitiveDataWarning 屬性

定義

取得或設定警告訊息的文字,當使用者嘗試從 WebPart 控制項匯出敏感性狀態資料時,會顯示此警告訊息文字。

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

屬性值

包含警告訊息的字串。 預設訊息為 .NET Framework 所提供的文化特性值。

範例

下列程式代碼範例示範 屬性的 ExportSensitiveDataWarning 宣告式用法。

下列網頁的程式代碼會使用標準 BulletedList 控件,並將它放在區域中。 控件會在運行時間以 GenericWebPart 控件包裝,讓控件成為真正的 WebPart 控件。 若要讓控件可匯出, ExportMode 屬性會新增至 <asp:bulletedlist> 元素,而屬性值會設定為 All,這表示可以匯出敏感性和非敏感數據。 另請注意,在 元素中 <asp:webpartmanager>ExportSensitiveDataWarning 屬性會指派自定義值。

請注意,若要讓程式代碼範例運作,您必須在 Web.config 檔案中新增一個設定,才能啟用匯出網頁元件描述檔案。 請確定您在與此程式碼範例網頁相同的目錄中有一個 Web.config 檔案。 在區 <system.web> 段中,請確定有屬性 <webParts> 設定為 enableExporttrue的專案,如下列標記所示。

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

在瀏覽器中載入頁面之後,單擊包含連結之控件標題列中的向下箭號) 表示的動詞功能表 (。 在動詞功能表中,選取 [ 導出],並注意到消息框會出現自定義警告。 如果您想要繼續匯出,請按兩下 [ 確定],這可讓您儲存 XML 描述檔案的本機複本,其中包含控制件的所有數據。

備註

當使用者嘗試從 WebPart 控件匯出機密狀態數據時,如果任何匯出的數據來自原始碼中標示為機密的成員,則會在消息框中向使用者顯示警告訊息,告知他們正在導出敏感數據,並提供取消匯出的機會。 開發人員可以在成員上將 屬性true[Personalizable] 參數設定isSensitive為 ,將特定成員的數據標示為敏感性。 如需此屬性和參數的詳細資訊,請參閱 PersonalizableAttribute 類別。

重要

當您使用 Web 元件的匯出功能時,敏感數據可能會匯出至未經授權的使用者。 如需如何防範此威脅的詳細資訊,請參閱 保護網頁元件頁面

每當用戶嘗試匯出時,就會顯示預設訊息。 不過,藉由將值指派給 ExportSensitiveDataWarning 屬性,您可以提供自定義警告訊息。

適用於

另請參閱