How to use ad controls:
An ad file is an XML file. All the tag attributes in the ad file are analyzed and placed in the adProperties dictionary for Attribute editing.
Ads. xml
Copy codeThe Code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! -- An advertisement file is an XML file -->
<Advertisements>
<Ad>
<ImageUrl> 4rwbgzby.gif </ImageUrl>
Http://www.jb51.net <NavigateUrl> </NavigateUrl>
<AlternateText> Text_01 </AlternateText>
<KeyWord> one </KeyWord>
<Impressions> 40 </Impressions>
<Aniaml> I'm using adRotator No.1 </Aniaml>
</Ad>
<Ad>
<ImageUrl> banner.jpg </ImageUrl>
Http://www.jb51.net <NavigateUrl> </NavigateUrl>
<AlternateText> Text_02 </AlternateText>
<KeyWord> two </KeyWord>
<Impressions> 40 </Impressions>
<Aniaml> I'm using adRotator No. 2 </Aniaml>
</Ad>
<Ad>
<ImageUrl> cvtxlkw4.gif </ImageUrl>
Http://www.jb51.net <NavigateUrl> </NavigateUrl>
<AlternateText> Text_03 </AlternateText>
<KeyWord> three </KeyWord>
<Impressions> 30 </Impressions>
<Aniaml> I'm using adRotator No. 3 </Aniaml>
</Ad>
</Advertisements>
AdRotator. aspx. cs
Copy codeThe Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Public partial class myTest_advertisement: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void ad_Created (object sender, AdCreatedEventArgs e)
{
If (string) e. AdProperties ["Animal"]! = "")
Label1.Text = (string) e. AdProperties ["Aniaml"];
Else
Label1.Text = "n. .";
}
}
AdRotator. aspx
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "adRotator. aspx. cs" Inherits = "myTest_advertisement" %>
<! 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> Using adRotator </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<H1> Adrotator Control <% -- Adrotator file -- %>
<Asp: AdRotator ID = "AdRotator1" runat = "server"
Target = "_ blank"
AdvertisementFile = "ads. xml"
OnAdCreated = "ad_Created"/>
<Br/>
Animal:
<Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label>
</Div>
</Form>
</Body>
</Html>
1. restructured the menu: extract the field (Ctrl + R, Ctrl + M) (Ctrl + R, Ctrl + F)
2. The dictionary keyword is Animal, which is converted to a string,
(String). AdProperties ["Aniaml"]