AdRotator.KeywordFilter 属性

定义

获取或设置类别关键字以筛选出 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

属性值

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 不会显示任何播发。 请务必在播发文件中为此属性指定至少一个匹配项的关键字。

适用于

另请参阅