AdRotator.KeywordFilter Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a category keyword to filter for specific types of advertisements in the XML advertisement file.
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
Property Value
The keyword to filter for specific types of advertisements in the XML advertisement file. The default value is an empty string ("").
- Attributes
Examples
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>
<%@ 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>
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>
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 the KeywordFilter 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 AdRotator control. Be sure to specify a keyword for this property with at least one match in the advertisement file.
Applies to
See also
.NET