AdRotator.KeywordFilter 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定分類關鍵字,以篩選 XML 廣告檔中特定類型的廣告。
public:
property System::String ^ KeywordFilter { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string KeywordFilter { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.KeywordFilter : string with get, set
Public Property KeywordFilter As String
屬性值
要篩選 XML 廣告檔中特定類型廣告的關鍵字。 預設值為空字串 ("")。
- 屬性
範例
下列程式碼範例示範如何使用 KeywordFilter 屬性來篩選遊戲相關廣告。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>AdRotator Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
Target="_self"
KeywordFilter="Games"
AdvertisementFile="~/App_Data/Ads.xml"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>AdRotator Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
Target="_self"
KeywordFilter="Games"
AdvertisementFile="~/App_Data/Ads.xml"/>
</form>
</body>
</html>
下列程式碼範例示範如何在 XML 公告檔案中指定每個廣告的關鍵字。 如需檔案格式的詳細資訊,請參閱 AdvertisementFile 成員。
<Advertisements>
<Ad>
<ImageUrl>~/Images/image1.jpg</ImageUrl>
<Height>60</Height>
<Width>190</Width>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Microsoft Main Site</AlternateText>
<Impressions>80</Impressions>
<Keyword>Business</Keyword>
<Caption>This is the caption for Ad#1</Caption>
</Ad>
<Ad>
<ImageUrl>~/Images/image2.jpg</ImageUrl>
<Height>90</Height>
<Width>90</Width>
<NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>
<AlternateText>Wingtip Toys</AlternateText>
<Impressions>80</Impressions>
<Keyword>Games</Keyword>
<Caption>This is the caption for Ad#2</Caption>
</Ad>
</Advertisements>
備註
XML 公告檔案中的每個廣告都可以指派類別關鍵字。 KeywordFilter使用 屬性來篩選指定關鍵字的公告。 只會針對控制項選取包含 關鍵字的 AdRotator 公告。 KeywordFilter屬性可以程式設計方式設定為符合使用者的設定檔。
屬性 KeywordFilter 是一個非常簡單的篩選準則,可搜尋指定的關鍵字。 您無法在 屬性中 KeywordFilter 指定多個關鍵字,也無法在廣告檔中宣告多個關鍵字。
注意
屬性 AdvertisementFile 必須設定,這個屬性才能有任何作用。
警告
如果在 XML 公告檔案中找不到指定的關鍵字,則控制項中 AdRotator 不會顯示任何廣告。 請務必在廣告檔案中指定至少一個相符專案的此屬性關鍵字。