Ajax Slide Show Control in ASP.NET



Today we see how easy the ASP.Net Ajax SlideShow Control is.

The Ajax Slide Show control is the same as in PowerPoint. The image changes after some time automatically, so now we start step wise methods.

Step 1. First you have to add a Scriptmanager

Step 2. Add a Lable and an Image control and three buttons for next, prev, stop and such.

Step 3. Now add a Slideshow Extender Control and go to the source and add some properties for the Slideshow like:

<asp:SlideShowExtender ID="SlideShowExtender1" runat="server" AutoPlay="true"
ImageDescriptionLabelID="lbldatails" TargetControlID="Image1" Loop="true" StopButtonText="Stop"
PlayButtonText="Play" NextButtonID="buttonNext" PreviousButtonID="buttonPrev"
PlayButtonID="buttonPlay" SlideShowServiceMethod="GetSlides" UseContextKey="True"></asp:SlideShowExtender>

Now go to the Image Control's smart tag and select Add Slideshow page method and write the following code:

        [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static AjaxControlToolkit.Slide[] GetSlides()
        {
            AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[4];
            slides[0] = new AjaxControlToolkit.Slide("images/a.jpg", "ered", "nice images");
            slides[1] = new AjaxControlToolkit.Slide("images/b.jpg", "dss", "nice images");
            slides[2] = new AjaxControlToolkit.Slide("images/c.jpg", "d", "nice images");
            slides[3] = new AjaxControlToolkit.Slide("images/d.jpg", "ds", "nice images");
            //return default(AjaxControlToolkit.Slide[]);
            //return default(AjaxControlToolkit.Slide[]);
            return slides;
        }


Similar Articles