一个图片广告控件
来源:互联网 发布:口语网络课程 编辑:程序博客网 时间:2024/05/01 02:50
一个图片广告控件
今天浏览163的新闻页面的时候,发现它的右侧的广告挺使用的,。呵呵,如图:
如果我们也把这个用在我们的网站上,不也挺好的吗,现在不知道为什么,一看到好用的东西,就想写个成控件,好像是深受MS的影响,用什么东西,就想拖过来,呵呵。
其实这个也没有什么难得,关键这个没有涉及到控件的事件,只在控件的呈现的过程中输出标签就行了。如果你是控件高手,就。。。。。。
开始做的时候,想用自定义数据源的,不过可一想,最多就有四条数据,干脆用Xml的了,我们可以在后台操作这个Xml就行了,这样省的给它做绑定了。说了这么多,看看代码吧
public class ImageControl : Control
{
private string _bigWidth = "360";
[Description("大图的宽度,如果大小合适,请使用默认值")]
[DefaultValue("360")]
public string BigWidth
{
get { return ViewState["BigWidth"] != null ? (string)ViewState["BigWidth"] : "360"; }
set { ViewState["BigWidth"] = value; }
}
private string _bigHeight = "240";
[Description("大图的高度,如果大小合适,请使用默认值")]
[DefaultValue("240")]
public string BigHeight
{
get { return ViewState["BigHeight"] != null ? (string)ViewState["BigHeight"] : "240"; }
set { ViewState["BigHeight"] = value; }
}
[Description("xml数据路径")]
[DefaultValue("Data.xml")]
private string _XmlPath = "";
public string XmlPath
{
get { return _XmlPath; }
set { _XmlPath = value; }
}
private string _smallWidth = "75";
[Description("小图的宽度,默认75")]
[DefaultValue("75")]
public string SmallWidth
{
get { return _smallWidth; }
set { _smallWidth = value; }
}
private string _smallHeight = "50";
[Description("小图的高度,默认50")]
[DefaultValue("50")]
public string SmallHeight
{
get { return _smallHeight; }
set { _smallHeight = value; }
}
private DataTable _dt ;
[Description("可以使用自定义数据源")]
public DataTable DataSource
{
get { return _dt; }
set { _dt = value; }
}
public ImageControl()
{
EnableViewState = false;
_XmlPath = XmlPath;
}
private void LoadXml()
{
DataSet ds = new DataSet();
ds.ReadXml(HttpContext.Current.Server.MapPath("~")+"//"+_XmlPath);
_dt = ds.Tables[0];
}.
{
private string _bigWidth = "360";
[Description("大图的宽度,如果大小合适,请使用默认值")]
[DefaultValue("360")]
public string BigWidth
{
get { return ViewState["BigWidth"] != null ? (string)ViewState["BigWidth"] : "360"; }
set { ViewState["BigWidth"] = value; }
}
private string _bigHeight = "240";
[Description("大图的高度,如果大小合适,请使用默认值")]
[DefaultValue("240")]
public string BigHeight
{
get { return ViewState["BigHeight"] != null ? (string)ViewState["BigHeight"] : "240"; }
set { ViewState["BigHeight"] = value; }
}
[Description("xml数据路径")]
[DefaultValue("Data.xml")]
private string _XmlPath = "";
public string XmlPath
{
get { return _XmlPath; }
set { _XmlPath = value; }
}
private string _smallWidth = "75";
[Description("小图的宽度,默认75")]
[DefaultValue("75")]
public string SmallWidth
{
get { return _smallWidth; }
set { _smallWidth = value; }
}
private string _smallHeight = "50";
[Description("小图的高度,默认50")]
[DefaultValue("50")]
public string SmallHeight
{
get { return _smallHeight; }
set { _smallHeight = value; }
}
private DataTable _dt ;
[Description("可以使用自定义数据源")]
public DataTable DataSource
{
get { return _dt; }
set { _dt = value; }
}
public ImageControl()
{
EnableViewState = false;
_XmlPath = XmlPath;
}
private void LoadXml()
{
DataSet ds = new DataSet();
ds.ReadXml(HttpContext.Current.Server.MapPath("~")+"//"+_XmlPath);
_dt = ds.Tables[0];
}.
来源:http://www.cnblogs.com/xbf321/archive/2008/03/19/image-control.html
- 一个图片广告控件
- asp.net 一个简单的图片广告控件
- 一个广告控件
- 秋天asp.net广告图片切换控件
- Android广告图片轮播控件
- Android广告图片轮播控件banner
- Android-----------广告图片轮播控件
- 一个能支持Flash的广告控件
- 一个flash的广告图片切换效果
- 用Fragment设置一个广告图片滑动
- 广告控件
- AdRotator控件动态的显示广告图片-必看必会
- Android广告图片轮播控件之banner
- iOS开发系列之常用自定义控件开发集—自动广告墙图片控件开发
- 自己做的一个图片框控件
- 将图片显示在一个控件上
- 广告控件用法
- 广告控件(AdRotator)
- and 和 ANDALSO的区别
- Struts2+Spring2+Hibernate3.2配置参考2
- Struts 2 + Spring 2 + Hibernate 3 整合入门详解
- taskfreak简介及安装指南
- Struts ajax
- 一个图片广告控件
- 框架:一个使用spring框架AOP的 例子
- Postfix 2.5 安装
- Request.ServerVariables参数汇总
- MYSQL常见出错代码 mysql error number
- 三星D828游戏下载
- 开发框架:详细的spring入门给大家共享
- 通用数据权限管理系统设计
- 王峻涛:传统B2C企业错过黄金时期