Export (0) Print
Expand All

AdRotator.KeywordFilter Property

Gets or sets a category keyword to filter for specific types of advertisements in the XML advertisement file.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[BindableAttribute(true)]
public string KeywordFilter { get; set; }
<asp:AdRotator KeywordFilter="String" />

Property Value

Type: System.String
The keyword to filter for specific types of advertisements in the XML advertisement file. The default value is an empty string ("").

Each advertisement in the XML advertisement file can be assigned a category keyword. Use the KeywordFilter property to filter the advertisements for the specified keyword. Only advertisements containing the keyword will be selected for the AdRotator control. The KeywordFilter property can be programmatically set to match the profile of the user.

The KeywordFilter property is a very simple filter that searches for the specified keyword. It is not possible to specify more than one keyword in the KeywordFilter property, nor is it possible to declare multiple keywords in the advertisement file.

NoteNote

The AdvertisementFile property needs to be set for this property to have any effect.

Caution noteCaution

If the specified keyword is not found in the XML advertisement file, no advertisement is displayed in the AdRotator control. Be sure to specify a keyword for this property with at least one match in the advertisement file.

The following code example demonstrates how to use the KeywordFilter property to filter for game-related advertisements.

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

The following code example demonstrates how to specify a keyword for each advertisement in the XML advertisement file. For more information on the file format, see the AdvertisementFile member.

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

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft