ASP. NET note-using AD controls

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.