广告控件的使用:
广告文件是一个XML文件,广告文件中所有的标签属性被分析后放到adProperties字典中,用以属性编辑。
ads.xml
1 2 34 5 12 134rwbgzby.gif 6http://www.cnblogs.com/daomul/ 7Text_01 8one 940 10I'm using adRotator No.1 1114 21 22banner.jpg 15http://www.cnblogs.com/daomul/ 16Text_02 17two 1840 19I'm using adRotator No.2 2023 30 31cvtxlkw4.gif 24http://www.cnblogs.com/daomul/ 25Text_03 26three 2730 28I'm using adRotator No.3 29
adRotator.aspx.cs
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 public partial class myTest_advertisement : System.Web.UI.Page 9 {10 protected void Page_Load(object sender, EventArgs e)11 {12 13 }14 protected void ad_Created(object sender, AdCreatedEventArgs e)15 {16 if ((string)e.AdProperties["Animal"] != "")17 Label1.Text = (string)e.AdProperties["Aniaml"];18 else19 Label1.Text = "n.a.";20 }21 }
adRotator.aspx
1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="adRotator.aspx.cs" Inherits="myTest_advertisement" %> 2 3 4 5 6 723 24Using adRotator 8 9 10
1、重构菜单:提取方法(Ctrl+R,Ctrl+M) 封装字段(Ctrl+R,Ctrl+F)
2、字典中的关键字是Animal, 该值转化为字符串,
(string).AdProperties["Aniaml"]