Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi Guys

Am trying to create a dynamic Image Slide Show using AjaxControlToolkit.Slide() with code I got online,But then I get the error below:
"Unknown web method GetSlides.
Parameter name: methodName "

Below is the code:

<script runat="Server" type="text/C#">
    public AjaxControlToolkit.Slide[] GetSlides()
        string[] fileNames = System.IO.Directory.GetFiles(Server.MapPath("images"));
        AjaxControlToolkit.Slide[] images = new AjaxControlToolkit.Slide[fileNames.Length];
        for (int i = 0; i < fileNames.Length; i++)
            string[] file = fileNames[i].Split('\\');
            images[i] = new AjaxControlToolkit.Slide("images/" + file[file.Length - 1], "", "");
        return images;

 <asp:Image ID="Image1" runat="server" 
                Style="border: 1px solid black;width:200" 
                AlternateText="Blue Hills image" />
     <asp:Button runat="Server" ID="prevButton" Text="Prev" Font-Size="Larger" />
            <asp:Button runat="Server" ID="playButton" Text="Play" Font-Size="Larger" />
            <asp:Button runat="Server" ID="nextButton" Text="Next" Font-Size="Larger" />
            <ajaxToolkit:SlideShowExtender ID="slideshowextend1"  runat="server" 
                Loop="true" />

This all runs in the client side, Why cant it find the web method GetSlides?
Updated 7-Feb-12 23:52pm

Have you written a webservice method called GetSlides for this code to call ? You don't say why you expect it SHOULD be able to find this method. Did you copy and paste and assume this code would work without writing that method ?
Share this answer

I had the same problem using the sample code couple years ago. I posted a solution on[^] Hope it will works for you too.


hi, i figured it out, we should include [System.Web.Script.Services.ScriptService], remove the static and everything remain the same. This will take care of the error "unknown web method GetSlides..." here is a sample for SlidesService.cs:

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Script.Services;

using System.Web.Services.Protocols;

using System.Configuration;

using System.Web.UI.WebControls;

using System.Web.UI;

/// <summary>

/// Summary description for SlidesService

/// </summary>

[WebService(Namespace = "<a rel="nofollow" target="_new" href=""></a>)]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


public class SlidesService : System.Web.Services.WebService {

   public SlidesService () {

       //Uncomment the following line if using designed components




   public AjaxControlToolkit.Slide[] GetSlides()


       System.Web.UI.WebControls.SqlDataSource ds = new SqlDataSource();

       ds.ConnectionString = ConfigurationManager.ConnectionStrings["pictureConnectionSt ring"].ConnectionString;

       string testConn = ConfigurationManager.ConnectionStrings["pictureConnectionSt ring"].ConnectionString;

       string mySelect;

       int count = 0;

       mySelect = "SELECT TOP 20 * FROM [pictureName] ORDER BY NEWID()";

       ds.SelectCommand = mySelect;

       System.Data.DataView dv = (System.Data.DataView)ds.Select(new DataSourceSelectArguments());

       count = dv.Table.Rows.Count;

       AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[count];



           for (int i = 0; i < count; i++)


               slides[i] = new AjaxControlToolkit.Slide("images/" + dv.Table.Rows[i]["path"].ToString(),





       catch { }

       //slides[0] = new AjaxControlToolkit.Slide("images/Blue hills.jpg", "Blue Hills", "Go Blue");

       //slides[1] = new AjaxControlToolkit.Slide("images/Sunset.jpg", "Sunset", "Setting sun");

       //slides[2] = new AjaxControlToolkit.Slide("images/Winter.jpg", "Winter", "Wintery...");

       //slides[3] = new AjaxControlToolkit.Slide("images/Water lilies.jpg", "Water lillies", "Lillies in the water");

       //slides[4] = new AjaxControlToolkit.Slide("images/VerticalPicture.jpg", "Sedona", "Portrait style picture");

       return (slides);



Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900