Display Advertisement Banners

Many Web sites use advertisement banners to generate income. ASP.NET gives you an AdRotator control that supports the process of displaying advertisements. The control supports displaying advertisements randomly. Each time a new page appears or is refreshed, an advertisement is selected.

The process of declaring the AdRotator control on your ASP.NET Web page is simple. Add the <ASP:AdRotator RUNAT="Server"> tag to the place on the page where you want the banner to be displayed. Then, create or modify a separate XML format file, called the advertisement file. This file contains the details about the advertisements. The details include the location of the graphic, the URL that the user is sent to when clicking the banner, and how often the advertisement should be displayed. Having this information in a separate XML file makes it easy to maintain the advertisements. The XML can be generated automatically through some server-side process or a programmer can modify it directly in the XML document.

For example, you can add advertisements to a Web page by declaring the AdRotator control. You can then modify an advertisement file with details on your ads. After you have done this, you can display an advertisement on your Web page. If you click Refresh, another advertisement may display.

DISPLAY ADVERTISEMENT BANNERS

DISPLAY ADVERTISEMENT BANNERS

4 Untitled - Notepad

File Edit Format Help

D Open the

GenericTemplate.aspx template from the Code Templates directory.

< Add a server form to the page.

L-Q Add an AdRotator Web server control to the page and specify the location of the advertisement file.

4 Untitled - Notepad

File Edit Format Help jsjx]

<Advertisements> <Ad>

«ImageUrMmages/mylifetimegoalsl gifi/lmageUrl-<NavigateUrl>hitp7/vww/.mylifetimegoals.com</NavigateUrl^ ■eAlternateTextsGo to mylifetimegoals.ccpm</AlternateTex> *4<eyword>Goalsetting=;/Keyword> <lmpressions>1 </lmpressions> </Ad> «Ad»

<lmageUrNmaqes/mylifetimegoals2.gif</lmageUrl> <NavigateUrl>http://www.mylifetimegoals.com</NavigateUrl> <AlternateText-Go to mylifetimegoals.conWAIternateTeixt» <Keyword>Goalsetting</Keyword> <lmpressions>1 </lmpressions> c/Ad> cAds

<lmageUrMmages/mylifetimegoals3.gif</lmageUrl> <NavigateUrl>http 7/wwla/ mylifetimegoals.com</NavigateUrl^ <AlternateText-Go to mylifetimegoals.com</AlternateText> ■iKeyword^Goalsetting</Keyword> ■e|inpressions>2</lmpre5sion5> c/Ad> </Advertisements>

D Open the

GenericTemplate.aspx template from the Code Templates directory.

< Add a server form to the page.

L-Q Add an AdRotator Web server control to the page and specify the location of the advertisement file.

0 View the contents of the advertisement file.

Was this article helpful?

0 0

Post a comment