ASP.NET图片轮换效果
哪位高手帮个忙啊!本人想用ASP.NET做图片轮换效果图片从数据库取数据在前台显示怎么做啊?有源码的最好希望能给我分享下小的会非常感谢!!...
哪位高手帮个忙啊!本人想用ASP.NET做图片轮换效果 图片从数据库取数据在前台显示怎么做啊?有源码的最好 希望能给我分享下 小的会非常感谢!!
展开
2个回答
展开全部
给个JS方法的图片轮换你参考一下:
首先,把下面代码做成一个加lh.js文件
// JavaScript Document
var PImgPlayer = {
_timer : null,
_items : [],
_container : null,
_index : 0,
_imgs : [],
intervalTime : 3000, //Time
init : function( objID,fontID,minID, w, h, time ){
this.intervalTime = time || this.intervalTime;
this._container = document.getElementById( objID );
this._font = document.getElementById(fontID);
this._min = document.getElementById(minID);
this._container.style.display = "block";
this._container.style.width = w + "px";
this._container.style.height = h + "px";
this._container.style.position = "relative";
this._container.style.overflow = "hidden";
this._container.style.border = "1px solid #fff";
var linkStyle = "display: block; TEXT-DECORATION: none;";
if( document.all ){
linkStyle += "FILTER:";
linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') ";
linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') ";
linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )";
linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()";
linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)";
linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )";
linkStyle += "progid:DXImageTransform.Microsoft.Inset ()";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )";
linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()";
linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )";
linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )";
linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )";
linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )";
linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%";
linkStyle += "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
}
//
var ulStyle = "margin:0;width:"+w+"px;position:absolute;z-index:999;right:5px;FILTER:Alpha(Opacity=30,FinishOpacity=90, Style=1);overflow: hidden;bottom:-1px;height:16px; border-right:1px solid #fff;";
//
var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
//
var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px;opacity: 0.6;";
baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
//
var ulHTML = "";
var ulMin = "";
for(var i = this._items.length -1; i >= 0; i--){
// var spanStyle = "";
// if( i==this._index ){
// spanStyle = baseSpacStyle + "background:#ff0000;";
// } else {
// spanStyle = baseSpacStyle + "background:#000;";
// }
// ulHTML += "<li style=\""+liStyle+"\">";
// ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
// ulHTML += "</li>";
var classStyle = "";
if( i==this._index ){
classStyle = "seleteMinPic";
} else {
classStyle = "MinPic";
}
ulMin = "<img class='"+classStyle+"' onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" alt=\"" + this._items[i].title + "\" src='"+this._items[i].img+"' />" + ulMin;
}
//
var html = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\" style=\""+linkStyle+"\"></a>";
this._container.innerHTML = html;
var link = this._container.getElementsByTagName("A")[0];
link.style.width = w + "px";
link.style.height = h + "px";
link.style.background = 'url(' + this._items[0].img + ') no-repeat center center';
//
this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
this._font.innerHTML = this._items[this._index].title;
this._min.innerHTML = ulMin;
},
addItem : function( _title, _link, _imgURL ){
this._items.push ( {title:_title, link:_link, img:_imgURL } );
var img = new Image();
img.src = _imgURL;
this._imgs.push( img );
},
play : function( index ){
if( index!=null ){
this._index = index;
clearInterval( this._timer );
this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
} else {
this._index = this._index<this._items.length-1 ? this._index+1 : 0;
}
var link = this._container.getElementsByTagName("A")[0];
if(link.filters){
var ren = Math.floor(Math.random()*(link.filters.length));
link.filters[ren].apply();
link.filters[ren].play();
}
link.href = this._items[this._index].link;
this._font.innerHTML = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\">"+ this._items[this._index].title +"</a>";
link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center';
//
var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体'; opacity: 0.6;";
baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
// var ulHTML = "";
var ulMin = "";
for(var i = this._items.length -1; i >= 0; i--){
// var spanStyle = "";
// if( i==this._index ){
// spanStyle = baseSpacStyle + "background:#ff0000;";
// } else {
// spanStyle = baseSpacStyle + "background:#000;";
// }
// ulHTML += "<li style=\""+liStyle+"\">";
// ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
// ulHTML += "</li>";
var classStyle = "";
if( i==this._index ){
classStyle = "seleteMinPic";
} else {
classStyle = "MinPic";
}
ulMin = "<img class='"+classStyle+"' onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" alt=\"" + this._items[i].title + "\" src='"+this._items[i].img+"' />" + ulMin;
}
//this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML;
this._font.innerHTML = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\">"+ this._items[this._index].title +"</a>";
this._min.innerHTML = ulMin;
},
mouseOver : function(obj){
var i = parseInt( obj.innerHTML );
if( this._index!=i-1){
obj.style.color = "#ff0000";
}
},
mouseOut : function(obj){
obj.style.color = "#fff";
}
}
然后在页面上引用这个JS,如:<script type="text/javascript" src="JS/lh.js"></script>
如在前台页面,可以这样显示:
<script type="text/javascript">
PImgPlayer.addItem( "abc", "#?id=282", "UploadFile/Pic/201011415932345276_min.jpg");
PImgPlayer.addItem( "cde”", "#?id=135", "UploadFile/Pic/2010114151252823810_min.jpg");
PImgPlayer.addItem( "fde", "#?id=124", "UploadFile/Pic/2010326113240195195_min.jpg");PImgPlayer.addItem( "医疗事故赔偿比其他事故赔偿还低 最高院将制定相关司法解释", "#?id=115", "UploadFile/Pic/2011630151553765595_min.jpg");PImgPlayer.addItem( "花交会看“花坚强”", "#?id=135", "UploadFile/Pic/2010114151252823810_min.jpg");
PImgPlayer.init( "imgADPlayer", "fontADPlayer", 320, 240 );
</script>
如后台来的放,可以在后台加这段JS,如:
string strPic = "";
strPic += "<script type=\"text/javascript\">";
List<InfoNet.Model.Article.Article> picList = new InfoNet.BLL.Article.Article().GetArticle("Article", 1, 5, " Where IsDel=0 And Pic<>null And pic<>'' order by id desc");
for (int i = 0; i < picList.Count; i++)
{
strPic += "PImgPlayer.addItem( \"" + picList[i].Title + "\", \"view.aspx?id=" + picList[i].ID + "\", \"" + picList[i].Pic + "\");";
}
strPic += "PImgPlayer.init( \"imgADPlayer\", \"fontADPlayer\", 320, 240 );";
strPic += "</script>";
然后注册strPic这个变量就行了,如:
ClientScript.RegisterClientScriptBlock(this.GetType(), "lh", strPic );
首先,把下面代码做成一个加lh.js文件
// JavaScript Document
var PImgPlayer = {
_timer : null,
_items : [],
_container : null,
_index : 0,
_imgs : [],
intervalTime : 3000, //Time
init : function( objID,fontID,minID, w, h, time ){
this.intervalTime = time || this.intervalTime;
this._container = document.getElementById( objID );
this._font = document.getElementById(fontID);
this._min = document.getElementById(minID);
this._container.style.display = "block";
this._container.style.width = w + "px";
this._container.style.height = h + "px";
this._container.style.position = "relative";
this._container.style.overflow = "hidden";
this._container.style.border = "1px solid #fff";
var linkStyle = "display: block; TEXT-DECORATION: none;";
if( document.all ){
linkStyle += "FILTER:";
linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') ";
linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') ";
linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )";
linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()";
linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)";
linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )";
linkStyle += "progid:DXImageTransform.Microsoft.Inset ()";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )";
linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )";
linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )";
linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()";
linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )";
linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )";
linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )";
linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )";
linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%";
linkStyle += "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
}
//
var ulStyle = "margin:0;width:"+w+"px;position:absolute;z-index:999;right:5px;FILTER:Alpha(Opacity=30,FinishOpacity=90, Style=1);overflow: hidden;bottom:-1px;height:16px; border-right:1px solid #fff;";
//
var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
//
var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px;opacity: 0.6;";
baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
//
var ulHTML = "";
var ulMin = "";
for(var i = this._items.length -1; i >= 0; i--){
// var spanStyle = "";
// if( i==this._index ){
// spanStyle = baseSpacStyle + "background:#ff0000;";
// } else {
// spanStyle = baseSpacStyle + "background:#000;";
// }
// ulHTML += "<li style=\""+liStyle+"\">";
// ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
// ulHTML += "</li>";
var classStyle = "";
if( i==this._index ){
classStyle = "seleteMinPic";
} else {
classStyle = "MinPic";
}
ulMin = "<img class='"+classStyle+"' onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" alt=\"" + this._items[i].title + "\" src='"+this._items[i].img+"' />" + ulMin;
}
//
var html = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\" style=\""+linkStyle+"\"></a>";
this._container.innerHTML = html;
var link = this._container.getElementsByTagName("A")[0];
link.style.width = w + "px";
link.style.height = h + "px";
link.style.background = 'url(' + this._items[0].img + ') no-repeat center center';
//
this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
this._font.innerHTML = this._items[this._index].title;
this._min.innerHTML = ulMin;
},
addItem : function( _title, _link, _imgURL ){
this._items.push ( {title:_title, link:_link, img:_imgURL } );
var img = new Image();
img.src = _imgURL;
this._imgs.push( img );
},
play : function( index ){
if( index!=null ){
this._index = index;
clearInterval( this._timer );
this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
} else {
this._index = this._index<this._items.length-1 ? this._index+1 : 0;
}
var link = this._container.getElementsByTagName("A")[0];
if(link.filters){
var ren = Math.floor(Math.random()*(link.filters.length));
link.filters[ren].apply();
link.filters[ren].play();
}
link.href = this._items[this._index].link;
this._font.innerHTML = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\">"+ this._items[this._index].title +"</a>";
link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center';
//
var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体'; opacity: 0.6;";
baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
// var ulHTML = "";
var ulMin = "";
for(var i = this._items.length -1; i >= 0; i--){
// var spanStyle = "";
// if( i==this._index ){
// spanStyle = baseSpacStyle + "background:#ff0000;";
// } else {
// spanStyle = baseSpacStyle + "background:#000;";
// }
// ulHTML += "<li style=\""+liStyle+"\">";
// ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
// ulHTML += "</li>";
var classStyle = "";
if( i==this._index ){
classStyle = "seleteMinPic";
} else {
classStyle = "MinPic";
}
ulMin = "<img class='"+classStyle+"' onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" alt=\"" + this._items[i].title + "\" src='"+this._items[i].img+"' />" + ulMin;
}
//this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML;
this._font.innerHTML = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\">"+ this._items[this._index].title +"</a>";
this._min.innerHTML = ulMin;
},
mouseOver : function(obj){
var i = parseInt( obj.innerHTML );
if( this._index!=i-1){
obj.style.color = "#ff0000";
}
},
mouseOut : function(obj){
obj.style.color = "#fff";
}
}
然后在页面上引用这个JS,如:<script type="text/javascript" src="JS/lh.js"></script>
如在前台页面,可以这样显示:
<script type="text/javascript">
PImgPlayer.addItem( "abc", "#?id=282", "UploadFile/Pic/201011415932345276_min.jpg");
PImgPlayer.addItem( "cde”", "#?id=135", "UploadFile/Pic/2010114151252823810_min.jpg");
PImgPlayer.addItem( "fde", "#?id=124", "UploadFile/Pic/2010326113240195195_min.jpg");PImgPlayer.addItem( "医疗事故赔偿比其他事故赔偿还低 最高院将制定相关司法解释", "#?id=115", "UploadFile/Pic/2011630151553765595_min.jpg");PImgPlayer.addItem( "花交会看“花坚强”", "#?id=135", "UploadFile/Pic/2010114151252823810_min.jpg");
PImgPlayer.init( "imgADPlayer", "fontADPlayer", 320, 240 );
</script>
如后台来的放,可以在后台加这段JS,如:
string strPic = "";
strPic += "<script type=\"text/javascript\">";
List<InfoNet.Model.Article.Article> picList = new InfoNet.BLL.Article.Article().GetArticle("Article", 1, 5, " Where IsDel=0 And Pic<>null And pic<>'' order by id desc");
for (int i = 0; i < picList.Count; i++)
{
strPic += "PImgPlayer.addItem( \"" + picList[i].Title + "\", \"view.aspx?id=" + picList[i].ID + "\", \"" + picList[i].Pic + "\");";
}
strPic += "PImgPlayer.init( \"imgADPlayer\", \"fontADPlayer\", 320, 240 );";
strPic += "</script>";
然后注册strPic这个变量就行了,如:
ClientScript.RegisterClientScriptBlock(this.GetType(), "lh", strPic );
展开全部
http://www.lanrentuku.com/js/jiaodiantu-794.html 。Jquery幻灯片焦点图插件,我现在在用你看看,还不错!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询