为什么我跑的时候看不到ajax幻灯片显示图像?

时间:2013-11-01 20:20:35

标签: asp.net ajax slideshow

我想在我的网站上播放一张ajax幻灯片。我从数据库中获取图片网址。

我认为代码是正确的,但是当我调试它时,我的数据库照片不会显示。

我确信我的照片完全加载了。

    <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajax:ToolkitScriptManager>
    <div align="center">
    <asp:Image ID="imgslides" runat="server" Height="400px" 
    ImageUrl="Gallery images/72007_205.jpg" BorderColor="Black" 
    BorderStyle="Solid" BorderWidth="5 px" />
    <asp:Button ID="btnPrevious" runat="server" Text="Prev" />
    <asp:Button ID="btnPlay" runat="server" Text="Play"  />
    <asp:Button ID="btnNext" runat="server" Text="Next"  />
    <ajax:SlideShowExtender ID="SlideShowExtender1" 
    runat="server" AutoPlay="true" Loop="true"    
    NextButtonID="btnNext" 
    PreviousButtonID="btnPrevious" 
    PlayButtonID="btnPlay" 
    PlayButtonText="Play" 
    StopButtonText="Stop"
    TargetControlID="imgslides" 
    SlideShowServiceMethod="GetSlides" 
    SlideShowServicePath = "Slideshow.asmx">
    </ajax:SlideShowExtender>

这是我的网络服务代码Slideshow.asmx

     public AjaxControlToolkit.Slide[] GetSlides()
    {
        SqlConnection myconn = new SqlConnection();
        myconn.ConnectionString = "Data Source=PARISA-PC;Initial Catalog=Images;Integrated Security=True";
        myconn.Open();
        string selectCmd = "select * from images";
        string countCmd = "select count(*) from images";
        SqlCommand myCmd = new SqlCommand(selectCmd,myconn);
        SqlCommand myCmd2 = new SqlCommand(countCmd,myconn);
        int i = 0;
        SqlDataReader dr = myCmd.ExecuteReader();
        ArrayList ar = new ArrayList();
        try
        {
            while (dr.Read())
            {
                ar.Add(dr.GetString(2));

            }
        }
        catch (Exception)
        {
            throw;
        }
        myconn.Close();
        AjaxControlToolkit.Slide[] Photos = new AjaxControlToolkit.Slide[ar.Count];
           for(i=0 ; i< ar.Count ; i++){
           Photos[i] = new AjaxControlToolkit.Slide(ar[i].ToString(),"image"+i.ToString(),"Booth's images");

       } 
        return Photos;


    }


  [1]: http://i.stack.imgur.com/eMw4S.jpg

1 个答案:

答案 0 :(得分:0)

您必须使用http处理程序或aspx页面(显示来自数据库的图像)。然后,您可以从ajax幻灯片Web服务将查询字符串发送到该处理程序或aspx以获取特定图像。你可以在Google上获得足够的关于它的例子。