zoukankan      html  css  js  c++  java
  • .net Asp AdRotator(广告控件)

    1.新建项目名称AdRotator

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

    <?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:广告的宽度。
    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 + "
    5秒后自动刷新");
            }
        }
    }
  • 相关阅读:
    WinForm 清空界面控件值的小技巧
    MVC 图片上传总是request.files.count() 等于0
    LinqToSQL 左连接右连接内链接
    C# utc datetime 互相转化
    mvc javascript form.submit()
    Java API中文版下载
    jQuery的链式操作
    【转】Eclipse/MyEclipse中使用复制粘贴功能卡的解决办法
    servlet什么时候被实例化?
    Jquery总结 $("h3 a", patch);
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3305474.html
Copyright © 2011-2022 走看看