ASP.NET笔记之广告控件的使用方法 广告控件的使用方法: 广告文件是一个XML文件,广告文件中所有的标签属性被分析后放到adProperties字典中,用以属性编辑。 ads.xml复制代码 代码如下: 4rwbgzby.gif //www.zwyuanma.com Text_01 one 40 I'm using adRotator No.1 banner.jpg //www.zwyuanma.com Text_02 two 40 I'm using adRotator No.2 cvtxlkw4.gif //www.zwyuanma.com Text_03 three 30 I'm using adRotator No.3 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."; } }adRotator.aspx复制代码 代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adRotator.aspx.cs" Inherits="myTest_advertisement" %> Using adRotator

Adrotator Control

<%--Adrotator文件--%>
Animal:
1、重构菜单:提取方法(Ctrl+R,Ctrl+M) 封装字段(Ctrl+R,Ctrl+F) 2、字典中的关键字是Animal, 该值转化为字符串, (string).AdProperties["Aniaml"]