Tuesday, September 17, 2013

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
4) Add new Web Page and ScriptManager , Image , Label , Three Buttons (For Play , Prev and Next) and AJAX SildeShow Extender
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<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>
1
2
3
4
5
6
7
8
9
10
11
12
13
[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;
 }

No comments:

Post a Comment