You are on page 1of 3

AdRotator.

KeywordFilter Property
.NET Framework 4 Other Versions
This topic has not yet been rated Rate this topic

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)

Syntax
C# C++ F# VB [BindableAttribute(true)] public string KeywordFilter { get; set; } ASP.NET <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 ("").

Remarks
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 theKeywordFilter property, nor is it possible to declare multiple keywords in the advertisement file.

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

Caution

If the specified keyword is not found in the XML advertisement file, no advertisement is displayed in the AdRot

Be sure to specify a keyword for this property with at least one match in the advertisement file.

Examples
The following code example demonstrates how to use the KeywordFilter property to filter for gamerelated advertisements. C# VB <%@ 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>

You might also like