2013-11-01 39 views
0

我想在我的網站上有一個ajax幻燈片。我從數據庫中獲取圖像網址。爲什麼運行時無法看到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> 

,這是我的web服務代碼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 

回答

0

你必須使用HTTP處理程序或一個aspx頁面(這顯示了從數據庫圖像)。然後,您可以將查詢字符串發送到該處理程序,或者從ajax幻燈片Web服務發送特定圖像的aspx。你可以在谷歌中獲得足夠的例子。