惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 小乔的闺房

学习ID,ClientID,UniqueID 基础知识1 (2)最简单的Remoting程序 (1)将对象序列化为bin,soap,xml (4)迭代器 (3)集合接口 (1)学习数组,集合,IEnumerable接口,引申学习迭代器 (2)学习集合,引申学习索引器和泛型 自定义服务器控件(1)整体把握(未完待续) FindControl实现原理 location详解 固定GridView列字符串长度,多于的用...代替 读取Excel数据到GridView相关问题(待完善) 说明nchar(10),char(10),nvarchar(10),varchar(10) syscolumns 获得数据库里所有表的名称 类[属性扩展],属性[属性扩展](待完善) 获得数据库表的列数 WebForm里弹出警告框之内的自定义类MessageBox
使用ASP.NET AJAX实现(图片)幻灯片效果
小乔的闺房 · 2007-10-15 · via 博客园 - 小乔的闺房

(1)html

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Photo.aspx.cs" Inherits="Photo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function pageLoad()
        {
            var img=$get("Image1");
            img.style.visibility="hidden";
            PageMethods.GetSlides(OnSuccess,OnError,OnTimeOut);
        }
               
        function OnSuccess(result)
        {
            slideshow.set_Slides(result);
            slideshow.set_Delay(5000);
            slideshow.ShowImage();
        }
               
        function OnError(result)
        {
            alert(result.get_message());
        }

        function OnTimeOut(result)
        {
            alert(result);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
            <Scripts>
                <asp:ScriptReference Path="~/ComJs/slide.js" />
            </Scripts>
        </asp:ScriptManager>
        <img alt="" id="Image1" style="FILTER: blendTrans(duration=1);visibility:hidden" height="300px" width="380px" border="0px" />
        <br />
        <input id="Button1" type="button"  value="1" onclick="slideshow.ShowUserChoose(0)" style="width:100px" />
        <input id="Button2" type="button"  value="2" onclick="slideshow.ShowUserChoose(1)" style="width:100px" />
        <input id="Button3" type="button"  value="3" onclick="slideshow.ShowUserChoose(2)" style="width:100px" />
        <input id="Button4" type="button"  value="4" onclick="slideshow.ShowUserChoose(3)" style="width:100px" />
    </form>
</body>
</html>

(2)aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;

public partial class Photo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static string[] GetSlides()
    {
        string[] strArrSlides = new string[4];
        strArrSlides[0] = "ComImage/01.jpg";
        strArrSlides[1] = "ComImage/02.jpg";
        strArrSlides[2] = "ComImage/03.jpg";
        strArrSlides[3] = "ComImage/04.jpg";
        return strArrSlides;
    }
}

(3)js

//注册ZHSlide命名空间
Type.registerNamespace("ZHSlide");

//创建一个名为SildeShow的类
ZHSlide.SlideShow=function()
{
    this._slides=new Array();//数组,存储图片URL
    this._delay=2000;//间隔时间,单位毫秒
    this._currentIndex=0;//当前图片在_slides数组中的索引
    this._pause=false;//是否暂停幻灯片的显示,(true暂停,false运行)
}

//属性(理解:不同于cs里的属性,这里是个笼统的概念)
ZHSlide.SlideShow.prototype=
{
    get_Slides:function()
    {
        return this._slides;
    },
   
    set_Slides:function(value)
    {
        this._slides=value;
    },
   
    get_Delay:function()
    {
        return this._delay;
    },
   
    set_Delay:function(value)
    {
        this._delay=value;
    },
   
    get_CurrentIndex:function()
    {
        return this._currentIndex;
    },
   
    //这个属性首先会检查传来的值.
    //如果值超出了_slides数组的范围,那会它会根据条件进行判断,设置该值为“0”或数组内元素总数减1.
    //其本质上就是让幻灯片可以循环播放.
    set_CurrentIndex:function(value)
    {
        if(value<0)
        {
            this._currentIndex=this._slides.length-1;
            return;
        }
        if(value>=this._slides.length)
        {
            this._currentIndex=0;
        }
        else
        {
            this._currentIndex=value;
        }
    },
   
    ShowUserChoose:function(number)
    {
        var img=$get("Image1");
        var slides=this.get_Slides();
        var curIndex=this.get_CurrentIndex();
        img.src=slides[number];
        if(img.style.visibility=="hidden")
        {
            img.style.visibility="visible";
        }
        img.filters.blendTrans.apply();//淡入淡出效果
        img.filters.blendTrans.play();  
        this.set_CurrentIndex(number);
        clearTimeout(_setTime);
        _setTime=window.setTimeout("slideshow.ShowImage()", this.get_Delay());
    },
   
    ShowImage:function()
    {
        var img=$get("Image1");
        var slides=this.get_Slides();
        var curIndex=this.get_CurrentIndex();
        img.src=slides[curIndex];
        if(img.style.visibility=="hidden")
        {
            img.style.visibility="visible";
        }
        img.filters.blendTrans.apply();//淡入淡出效果
        img.filters.blendTrans.play(); 
        this.set_CurrentIndex(curIndex+1);
        _setTime=window.setTimeout("slideshow.ShowImage()", this.get_Delay());
    }
}

//注册SildeShow的类
ZHSlide.SlideShow.registerClass("ZHSlide.SlideShow");

var slideshow=new ZHSlide.SlideShow();