AJAX Toolkits -- SlideShow

在AJAX Toolkits中有个SlideShow扩展控件,其主要是对于Image控件的。

该功能能实现循环暂时大批图片,像放幻灯一样。其属性有:

SlideShowServicePath - Path to the webservice that the extender will pull the images from. (我认为这个可以不用) SlideShowServiceMethod - 处理的方法名。用户在将扩展控件添加到Image控件之后,可以用同样的操作方法,在后台添加一个方法,其函数默认为GetSlide ContextKey - User/page specific context provided to an optional overload of the web method described by ServiceMethod/ServicePath. If the context key is used, it should have the same signature with an additional parameter named contextKey of type string:

      [System.Web.Services.WebMethod]
      [System.Web.Script.Services.ScriptMethod]
         public AjaxControlToolkit.Slide[] GetSlides(string contextKey)

Note that you can replace "GetSlides" with a name of your choice, but the return type and parameter name and type must exactly match, including case.

UseContextKey - Whether or not the ContextKey property should be used. This will be automatically enabled if the ContextKey property is ever set (on either the client or the server). If the context key is used, it should have the same signature with an additional parameter named contextKey of type string (as described above). 这里我是设置为True NextButtonID - ID of the button that will allow you to see the next picture. (由于我不需要则没有设置) PlayButtonID - ID of the button that will allow you to play/stop the slideshow. (由于我不需要则没有设置) PreviousButtonID - ID of the button that will allow you to see the previous picture. (由于我不需要则没有设置) PlayButtonText - The text to be shown in the play button to play the slideshow. (由于我不需要则没有设置) StopButtonText - The text to be shown in the play button to stop the slideshow. (由于我不需要则没有设置) PlayInterval - 每个画面的间隔时间,毫秒级. ImageTitleLabelID - 图片名称对应的Label编号,可以不用. ImageDescriptionLabelID - 图片描述对应的Label编号,可以不用. Loop - 布尔型,是否循环播放. AutoPlay - 布尔型,是否自动播放.

 

示例代码:

这里比较特殊的是,其还包含后台代码,后台主要是返回需要播放的图片集合,如下:

ContractedBlock.gif ExpandedBlockStart.gif Code
 1[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
 2    public static AjaxControlToolkit.Slide[] GetSlides(string contextKey)
 3ExpandedBlockStart.gifContractedBlock.gif    {
 4ExpandedSubBlockStart.gifContractedSubBlock.gif        return new AjaxControlToolkit.Slide[] 
 5            new AjaxControlToolkit.Slide("Image/1.jpg""1""Go Blue"),
 6            new AjaxControlToolkit.Slide("Image/2.jpg""2""Go Blue"),
 7            new AjaxControlToolkit.Slide("Image/3.jpg""3""Setting sun"),
 8            new AjaxControlToolkit.Slide("Image/4.jpg""4""Wintery"),
 9            new AjaxControlToolkit.Slide("Image/5.jpg""5""Lillies in the water"),
10            new AjaxControlToolkit.Slide("Image/6.jpg""6""Portrait style picture")}
;
11    }

 

其中有三个变量,第一个是图片的路径,第二个是图片的标题(对应于标题Label),第三个是图片的描述(对应于描述Label)

而前台代码是:

ContractedBlock.gif ExpandedBlockStart.gif Code
 1<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
 2    <div style="text-align: center; width: 300px">
 3        <asp:Label ID="imageTitle" runat="server"></asp:Label>
 4        <asp:Image ID="Image1" runat="server" Height="300px" Style="border: 1px solid black;
 5            width: auto" ImageUrl="~/testPages/Image/1.jpg" AlternateText="Image 1" />
 6        <asp:Label runat="server" ID="imageDescription"></asp:Label>
 7        
 8        <cc1:SlideShowExtender ID="Image1_SlideShowExtender" runat="server" Enabled="True"
 9            SlideShowServiceMethod="GetSlides" SlideShowServicePath="" TargetControlID="Image1"
10            UseContextKey="True" AutoPlay="true" Loop="true" ImageTitleLabelID="imageTitle"
11            ImageDescriptionLabelID="imageDescription" PlayInterval="2000">
12        </cc1:SlideShowExtender>
13    </div>
14</asp:Content>

 

特别主要,后台传入的图片路径和前台的URL是不完全相同的

转载于:https://www.cnblogs.com/lx0831/archive/2009/01/06/1370055.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值