首页 技术 正文
技术 2022年11月9日
0 收藏 853 点赞 3,404 浏览 1938 个字

1.新建项目名称AdRotator

2.右键项目名称添加一个xml文件命名为AdRotator.xml

.net Asp AdRotator(广告控件)

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>images/1.jpg</ImageUrl>
<NavigateUrl>http://www.Microsoft.com</NavigateUrl>
<AlternateText>图像不用时显示的文本</AlternateText>
<Keyword>可用于筛选特定的广告的广告类别</Keyword>
<Impressions>1000</Impressions>
<Height>200</Height>
<Width>1000</Width>
</Ad>
<Ad>
<ImageUrl>images/2.jpg</ImageUrl>
<NavigateUrl>http://www.asp.net</NavigateUrl>
<AlternateText>图像不用时显示的文本</AlternateText>
<Keyword>可用于筛选特定的广告的广告类别</Keyword>
<Impressions>300</Impressions>
<Height>200</Height>
<Width>1000</Width>
</Ad>
</Advertisements>

3.新建一个Images文件夹,添加三张图片

4.在页面中拖一个AdRotator控件,并设置他的属性

AD Rotator控件的所有属性都是可选的。一般来说,XML文件中可以包含下列属性:1、ImageUrl:要显示的图像的URL。2、NavigateUrl:单击AD Rotator控件要转到的网页的URL。3、AlternateText:图像不可用时显示的文本。4、Keyword:可用于筛选特定的广告的广告类别。5、Impressions:一个指示广告的可能显示频率的数值(加权数)。在XML文件中,所有Impressions值的总和不能超过2,048,000,000-1。6、Height:广告的高度。 不选择高度宽度,默认显示图片的大小7、Width:广告的宽度。.net Asp AdRotator(广告控件)4.

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AdRotatorDemo._Default" %><!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>AdRotator 控件使用示例</title>
<meta http-equiv = "refresh" content="5;url=Default.aspx" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>AdRotator 控件使用示例</h3>
<p>
<asp:AdRotator ID="AdRotator1" runat="server"
OnAdCreated="AdRotator1_AdCreated" AdvertisementFile="~/ad.xml"/>
</p>
</div>
<p>
&nbsp;</p>
</form>
</body>
</html>
<script runat="server">
</script>

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;namespace AdRotatorDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void AdRotator1_AdCreated(object sender, AdCreatedEventArgs e)
{
Response.Write("名称:" + e.AlternateText + "\n5秒后自动刷新");
}
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918