本文介绍了如何使用adrotator控件显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用adrotator控件在我的网络应用程序中显示广告。但它只显示替代文字而不是图片。我的代码是:
I am using adrotator control to display ads in my web application.But it is displaying alternate text only and not images.My code is:
<Advertisements>
<Ad>
<Imageurl>~/adsimages/deal1.jpg</Imageurl>
<Navigateurl>http://localhost:56788/adsimages/deal1.jpg</Navigateurl>
<AlternateText>NEW DEALS</AlternateText>
<Impressions>5</Impressions>
</Ad>
<Ad>
<Imageurl>~/adsimages/images(1).jpg</Imageurl>
<Navigateurl>http://localhost:56788/adsimages/images (1).jpg</Navigateurl>
<AlternateText>CHECK OUT NEW DEALS</AlternateText>
<Impressions>3</Impressions>
</Ad>
</Advertisements>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/ads.xml" Target="_blank"/>
推荐答案
XML file attributes
ImageUrl - The URL of the image to display
NavigateUrl - The URL to navigate to, when the ad is clicked
AlternateText - The text to use if the image is missing
Keyword - Used by the adrotator control to filter ads
Impressions - A numeric value (a weighting number) that indicates the likelihood of how often the ad is displayed
Create an asp.net web application project, and add an XML file. Name the XML file as AdsData.xml. Copy and paste the following in the XML file.
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/Images/Google.png</ImageUrl>
<NavigateUrl>http://google.com</NavigateUrl>
<AlternateText>Please visit http://www.Google.com</AlternateText>
<Impressions>10</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/Pragim.png</ImageUrl>
<NavigateUrl>http://pragimtech.com</NavigateUrl>
<AlternateText>Please visit http://www.pragimtech.com</AlternateText>
<Impressions>20</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/Youtube.png</ImageUrl>
<NavigateUrl>http://Youtube.com</NavigateUrl>
<AlternateText>Please visit http://www.Youtube.com</AlternateText>
<Impressions>40</Impressions>
</Ad>
</Advertisements>
Create an Images folder in the project, and add three images.
Drag and Drop the AdRotator control on the webform. Set AdvertisementFile="~/AdsData.xml".
<asp:AdRotator AdvertisementFile="~/AdsData.xml" ID="AdRotator1" runat="server" />
To open the target web page in a separate browser window, set Target="_blank"
Use KeyWord attribute to filter ads.
The KeywordFilter and AdvertisementFile properties can be changed at runtime also.
这篇关于如何使用adrotator控件显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!