30 April 2007
Dynamic AJAX Slideshows
The most recent version of the ASP.NET AJAX Control Toolkit came with a new control called SlideShow. This is a nifty little control that extends the ASP.NET image control into an AJAX slideshow. It uses a web service call to retreive the images of the slideshow. This web service call just returns an array of "AjaxControlToolkit.Slide".
So in the example that comes with the toolkit, there are four or five hard coded images in the array. This really is not very useful in a real life scenario. Most of the time if you are displaying a slideshow, these images will need to be filled dynamically either through a database, or my flavor of choice, from the file system.
What I wanted to be able to do was just add an image to my assigned photos directory, and have it automatically show up in my slideshow. No admin section, no file uploader, and no database.
To do this I create a class called 'PhotoGallery' with a public shared function called 'GetSlides'. GetSlides returns as an array of "AjaxControlToolkit.Slide". This function goes out to my file system, returns all the files in the given directory, and adds them to the array. It really is that simple.
I am sure there is a bit simplier way to do this, as far as the array. You can download my VB.NET class below.
[ DOWNLOAD CODE ]