Home > AJAX, ASP.Net > AJAX SlideShow Extender with Images from Folder

AJAX SlideShow Extender with Images from Folder


Hi all,

try this example to use Ajax SlideShow Extender with Images from Folder

1) Open VS2008 and create a new website

2) Create Folder in website Root and add your images that you want to display using AJAX SlideShow Extender name it “Images”

3) Add WebSerive name it “Slideshow.asmx” and add the following Code


[System.Web.Services.WebMethod]
 [System.Web.Script.Services.ScriptMethod]
 public AjaxControlToolkit.Slide[] GetSlides()
 {
 string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Images"));
 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("Images/" + file[file.Length - 1], file[file.Length - 1], "");
 }
 return photos;
 }

4) Add new Web Page and ScriptManager , Image , Label , Three Buttons (For Play , Prev and Next) and AJAX SildeShow Extender


<ajax:ToolkitScriptManager ID="scriptmanager1" runat="server">
 </ajax:ToolkitScriptManager>
 <div>
 <table style="border: Solid 3px #D55500; width: 400px; height: 400px" cellpadding="0"
 cellspacing="0">
 <tr style="background-color: #D55500">
 <td style="height: 10%; color: White; font-weight: bold; font-size: larger" align="center">
 <asp:Label ID="lblTitle" runat="server"></asp:Label>
 </td>
 </tr>
 <tr>
 <td>
 <asp:Image ID="imgslides" runat="server" Height="400px" Width="400px" ImageUrl="~/Images/1.JPG" />
 </td>
 </tr>
 <tr>
 <td align="center">
 <asp:Label ID="lblimgdesc" runat="server"></asp:Label>
 </td>
 </tr>
 <tr>
 <td align="center">
 <asp:Button ID="btnPrevious" runat="server" Text="Prev" CssClass="button" />
 <asp:Button ID="btnPlay" runat="server" Text="Play" CssClass="button" />
 <asp:Button ID="btnNext" runat="server" Text="Next" CssClass="button" />
 </td>
 </tr>
 </table>
 <ajax:SlideShowExtender runat="server" AutoPlay="true" ImageTitleLabelID="lblTitle"
 ImageDescriptionLabelID="lblimgdesc" Loop="true" NextButtonID="btnNext" PreviousButtonID="btnPrevious"
 PlayButtonID="btnPlay" PlayButtonText="Play" StopButtonText="Stop" TargetControlID="imgslides"
 SlideShowServicePath="Slideshow.asmx" SlideShowServiceMethod="GetSlides">
 </ajax:SlideShowExtender>
 </div>

Hope this helps

Good Luck

Advertisements
Categories: AJAX, ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: