您现在的位置是:网站首页> 编程资料编程资料
ASP.NET 广告控件AdRotator的使用方法与实例_实用技巧_
2023-05-24
284人已围观
简介 ASP.NET 广告控件AdRotator的使用方法与实例_实用技巧_
adRotator.aspx,在ASP.NET页面中创建一个AdRotator服务器控件,将广告XML文件连接到这个控件。使用以下服务器控件标记来完成
生成广告的代码
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.";
}
}
xml文档格式
图片路径(本地)
图片连接
鼠标放上去时提示语
关键字
优先级
图片路径(本地)
图片连接
鼠标放上去时提示语
关键字
优先级
图片路径(本地)
图片连接
鼠标放上去时提示语
关键字
优先级
注xml
AdvertisementFile:包含广告信息的XML
BorderColor:为广告设置边界颜色,如 BorderColor="#000000" 将边界设为黑色
BorderWidth:边界宽度,单位是象素,如 BorderWidth="1"
CssClass:来自CSS文件或inline STYLE 元素的字体类,如CssClass="clsAds"
Height:广告图象的高度,单位是象素
KeywordFilter:对广告类别进行过滤,如上面例子中所见的
Target:点击广告时URL的目标窗口。如Target="_new" ,每当广告图象被点击都会产生一个新窗口。 “_top”是默认值
Width:广告图象的宽度,单位是象素
AdRotator控件的KeywordFilter属性可以对某一特定类别的广告进行过滤
复制代码 代码如下:
生成广告的代码
复制代码 代码如下:
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.";
}
}
xml文档格式
复制代码 代码如下:
注xml
AdvertisementFile:包含广告信息的XML
BorderColor:为广告设置边界颜色,如 BorderColor="#000000" 将边界设为黑色
BorderWidth:边界宽度,单位是象素,如 BorderWidth="1"
CssClass:来自CSS文件或inline STYLE 元素的字体类,如CssClass="clsAds"
Height:广告图象的高度,单位是象素
KeywordFilter:对广告类别进行过滤,如上面例子中所见的
Target:点击广告时URL的目标窗口。如Target="_new" ,每当广告图象被点击都会产生一个新窗口。 “_top”是默认值
Width:广告图象的宽度,单位是象素
AdRotator控件的KeywordFilter属性可以对某一特定类别的广告进行过滤
您可能感兴趣的文章:
相关内容
- Global.asax取物理路径/取绝对路径具体方法_实用技巧_
- asp.net运算符之逻辑运算符以及其他运算符介绍与实例_实用技巧_
- asp.net中url字符串编码乱码的原因与解决方法_实用技巧_
- asp.net中DBNull.Value,null,String.Empty区别浅析_实用技巧_
- 分享Visual Studio原生开发的10个调试技巧_实用技巧_
- asp.net updatepanel 导致JS不能加载,而无法使用的解决方法_实用技巧_
- Asp.net FileUpload+Image制作头像效果示例代码_实用技巧_
- Asp.net第三方控件ComboBox组合框介绍_实用技巧_
- Asp.net_Table控件の单元格纵向合并示例_实用技巧_
- asp.net利用NamingContainer属性获取GridView行号的方法_实用技巧_
