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

屬性值

String

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

範例

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

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

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

<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 組件 的匯出功能時,可能會將敏感性資料匯出至未經授權的使用者。 如需如何防範此威脅的詳細資訊,請參閱保護Web 組件頁面

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

適用於

另請參閱