none
SlideShowExtender这个ajax控件怎么用啊?? RRS feed

  • 问题

  • 我的前台代码是

    <form id="form1" runat="server">
        <div>
    
             
    
    
            <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </ajaxToolkit:ToolkitScriptManager>
    
    
    
            <asp:Image ID="Image1" runat="server" Height="300" Width="400" Style="border: 1px solid black;" /><br />
        
            <asp:Button runat="Server" ID="prevButton" Text="Prev" />
            <asp:Button runat="Server" ID="playButton" Text="Play" />
            <asp:Button runat="Server" ID="nextButton" Text="Next" />
            
            
            <ajaxToolkit:SlideShowExtender ID="SlideShowExtender1" runat="server" 
            TargetControlID="Image1"
                SlideShowServicePath="ShowPictureWebService.asmx" 
                SlideShowServiceMethod="GetSlides"
                NextButtonID="nextButton" 
                PlayButtonID="playButton"
                 PreviousButtonID="prevButton"
                  SlideShowAnimationType="FadeInOut"
                   AutoPlay="true"
              >
            </ajaxToolkit:SlideShowExtender>
        </div>
        </form>


    后台的web服务是这样子写的

      public class ShowPictureWebService : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
    
    
            [WebMethod]
            public static AjaxControlToolkit.Slide[] GetSlides()
            {
                return new AjaxControlToolkit.Slide[] { 
                new AjaxControlToolkit.Slide("images/a.jpg" , "Go Blue", "aaa"),
                new AjaxControlToolkit.Slide("images/b.jpg", "Sunset", "bbb")
                };
            }
        }

    我的images文件夹里面明明有两个图片,为什么就是播放不了啊???

    • 已移动 Caillen 2013年10月29日 6:26 ASP.NET Ajax问题。
    2013年10月28日 7:07

全部回复

  • 你好,

        你首先需要下载,安装AjaxControlToolkit:http://ajaxcontroltoolkit.codeplex.com/releases/view/112805

         你可以从ASP.NET Ajax下载完整的项目:http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/SlideShow/SlideShow.aspx

         SlideShowExtender这个ajax控件其实使用很简单的,你可以看看下面这个demo:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SlideShow.aspx.cs" Inherits="SlideShow" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <!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>SlideShow</title>
        
        <script runat="Server" type="text/C#">
            [System.Web.Services.WebMethod]
            [System.Web.Script.Services.ScriptMethod]
    
            public static AjaxControlToolkit.Slide[] GetSlides()
            {
                AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[5];
                slides[0] = new AjaxControlToolkit.Slide("images/Image1.jpg", "First image of my album", "First Image");
                slides[1] = new AjaxControlToolkit.Slide("images/Image2.jpg", "Second image of my album", "Second Image");
                slides[2] = new AjaxControlToolkit.Slide("images/Image3.jpg", "Third image of my album", "Third Image");
                slides[3] = new AjaxControlToolkit.Slide("images/Image4.jpg", "Fourth image of my album", "Fourth Image");
                slides[4] = new AjaxControlToolkit.Slide("images/Image5.jpg", "Fifth image of my album", "Fifth Image");
                return (slides);
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <table width="400px" align="center" height="350px" bgcolor="silver">
                <tr align="center">
                    <td>
                        <asp:ScriptManager ID="ScriptManager2" runat="server" />
                        <asp:Label ID="lableImageDetail" runat="server" ForeColor="#000000" />
                    </td>
                </tr>
                <tr align="center">
                    <td>
                        <asp:Image runat="server" ID="image1" Height="250" Width="300" />
                    </td>
                </tr>
                <tr align="center">
                    <td>
                        <asp:Button ID="buttonPrev" runat="Server" Text="Previous" Width="80px" />
                        <asp:Button ID="buttonPlay" runat="server" Text="Play" Width="80px" />
                        <asp:Button ID="buttonNext" runat="Server" Text="Next" Width="80px" />
                    </td>
                </tr>
            </table>
    
            <ajaxToolkit:SlideShowExtender ID="slideShowExtender1" runat="Server" TargetControlID="image1"
    ImageDescriptionLabelID="lableImageDetail" Loop="true" AutoPlay="true" StopButtonText="Stop" 
    PlayButtonText="Play" NextButtonID="buttonNext" PreviousButtonID="buttonPrev"
    PlayButtonID="buttonPlay" SlideShowServiceMethod="GetSlides" />
        </form>
    </body>
    </html>
    
    

      读下面的链接了解更多信息:

     http://www.c-sharpcorner.com/uploadfile/prathore/ajax-slideshowextender-control/


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2013年10月30日 2:28
    版主
  • 大侠,我的代码跟您的代码好像没有什么差别啊??我的为什么显示不了图片
    2013年11月3日 6:34