在幻灯片放映器扩展器Asp.net C#上显示数据库中的图像

时间:2013-01-17 05:12:41

标签: c# asp.net ajax

我曾尝试过很多方法在AJAX的图像滑块上显示图像bt它们都没有工作。请帮助解决错误。

<asp:ToolkitScriptManager
    ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Image ID="Image2" runat="server" Height="200px" Width="315px" />
<asp:SlideShowExtender ID="Image1_SlideShowExtender" runat="server" 
 TargetControlID="Image2"  SlideShowServiceMethod="GetSlides" 
 SlideShowServicePath="WebService.asmx"  PreviousButtonID="Button1"  PlayButtonID="Button2"  
 NextButtonID="Button3"  PlayButtonText="Play"  StopButtonText="Stop"  AutoPlay="true"  Loop="true">

                                 </asp:SlideShowExtender>

在Webservice.asmx.cs文件中

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 


[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]

public AjaxControlToolkit.Slide[] GetSlides()  
{
    string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Pic"));
    AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[imagenames.Length];
    for (int i = 0; i < imagenames.Length; i++)
    {
        string[] file = imagenames[i].Split('\\');
        photos[i] = new AjaxControlToolkit.Slide("Pic/" + file[file.Length - 1], file[file.Length - 1], "");
    }
    return photos;
}
}

}

1 个答案:

答案 0 :(得分:0)

[System.Web.Script.Services.ScriptService]

取消注释此行 您的幻灯片扩展器将开始工作