asp.net advertising control AdRotator using methods and examples _ practical skills

Source: Internet
Author: User
Tags border color
Adrotator.aspx, create a AdRotator server control on the asp.net page to connect the ad XML file to this control. Use the following server control tags to complete the
Copy Code code as follows:

<asp:adrotator id= "AdRotator1" runat= "Server" advertisementfile= "~/xmlfile.xml"/>

Code to generate Ads
Copy Code code as follows:

AdRotator.aspx.cs
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.a."
}
}

XML Document Format
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<Advertisements>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
</Advertisements>

Note XML
AdvertisementFile: XML containing advertising information
BorderColor: Sets the border color for the advertisement, such as bordercolor= "#000000" to set the boundary to black
BorderWidth: Boundary width, Unit is pixel, such as borderwidth= "1"
CssClass: A font class from a CSS file or inline STYLE element, such as cssclass= "Clsads"
Height: Advertisement image altitude, Unit is pixel
KeywordFilter: Filter The advertising category, as seen in the example above
Target: The destination window for the URL when clicking on the ad. such as target= "_new", every time the ad image is clicked will produce a new window. "_top" is the default value
Width: The breadth of the advertising image, in pixels
The KeywordFilter property of a AdRotator control can filter a specific category of ads
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.