Here I will explain how to show images slideshow using Ajax Slideshowextender control from root folder in asp.net
Description:
Previously I explained how to insert images into our project folder and display the images from folder in gridview based on images path in database using asp.net check this link here
SlideShow is an extender that targets image controls. You can provide it with buttons to hit previous, next and play. You can configure the slideshow to play automatically on render, allow it loop through the images in a round robin fashion and also set the interval for slide transitions. You can use a page method to supply images to the slide show or use a webservice
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" TagPrefix="ajax" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>AJAX Slidshow Extender Example</title>
<style type="text/css">
.button
{
border:solid 1px #c0c0c0;
background-color:#D55500;
color:#ffffff;
cursor:pointer;
font-weight:bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<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" />
</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>
</form>
</body>
</html>
|
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public AjaxControlToolkit.Slide[] GetSlides()
{
……
……
}
|
/// <summary>
/// Summary description for Slideshow
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Slideshow : System.Web.Services.WebService {
public Slideshow () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[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;
}
}
|
|
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
|


Subscribe by RSS
Subscribe by Email
30 comments :
its so nice
great work ya...nice
and asp.net vb?
i have a gallery which contain more than one album.. whihc stores images of all album in same folder... how can i use slideshow album wise...
Thanks man. very helpful.
Dear Suresh,
I this tutorial extremely useful, it is the one that I was looking for hours. But I need to modify it a bit like follow:
I don't need a play button to use it to play but to get the full link of image and set for example to and textbox!! If you could help me on that it will be highly appreciated.
However thanks a lot for sharing.
Armend
how can I make it that when I click on an image, the image will be shown as popup?
@Josey..
check these posts
show image in popup whenever click on image
Image slideshow gallery in asp.net
iTS rEALLY SUPERBB YAAR.. THNKS
nice work dude. Appriciate
Thanks dear its very usefull to me...because i were face problems to show images using below code
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[3];
slides[0] = new AjaxControlToolkit.Slide("8.jpg", "Image1", "house");
slides[1] = new AjaxControlToolkit.Slide("9.jpg", "Image2", "seaside");
slides[2] = new AjaxControlToolkit.Slide("img05.jpg", "Image3", "car");
return (slides);
but after apply ur code my problem is solved..now i enjoy Slideshow in my Testing Website..
Hi
nice coding but this is one time slideshow for images but if i want to do more that one time with different images then what to do and how to save this slideshow in our computer
Done Same code... but nothing happen...
I write code in contentPlaceHolder...
please help me with it...
thanks in advance...
Dear Suresh,
Nice tutorial very useful.
But how can i apply effects to images that means Image will slide from left to right or vice versa.
Please Help !!!!!!!!!!!!!
Hi,
I have developed an web application which display top blogs added by the user to that website.
I am displaying data in gridview. i have given pagination to gridview.
Now i want that "if i scroll down the page, then gridview automatically expands.
Ex: Initially it contains 10 records, when i scroll down page at bottom it should show me next 10(Total 20) record, again when i scroll down it should again show me next 10(Total 30) records without refreshing the page.
This is just like facebook, when you scroll down the page it automatically shows you older posts.
how to prevent click previous button when first image is displaying
its not working in my case i hv done with same instructions...
How To set a hyperlink on the image?
hi Suresh ..,
This is Nice. and i will develop a Photo Gallery for my existing site .. My Requirement is i have a moster page div tag ie Gallery .. and i will create a special folder ie Admin .Then i will give access to Admin to upload a image file to DB from admin access page and it will show or Reflect to total all other pages .. how to write a code?
Hi Suresh this is very nice. may i know how to implement the same with ashx file my concept is images stored in database as binary format and i need to retrive those images and presented in a ajax slide extender control is it possible to do..?
Hello, I am trying to implement this, but in this line: string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Images"));
We have the pictures ina virtual directory, so I read from the database something like this "http://myhost/mypirctures/image1.jpg" and so on. How can I do it???
sir, vb.code pls..
that is very helpful
Dear Suresh thank you. Your code is very helpful for the asp.net lovers like me.
Thank you very much.
Hi, im not able to see the images.. i gave the folder name in the code :(
lukin good suresh..hahahah :) :)
I want to pass the location of image from database to slideshowextender (getslide() method)..Please help friend....
Thanks..
I want to pass the location of image from database to slideshowextender (getslide() method)..Please help friend....
Thanks..
Helpful advice in Ajax Slideshowextender control. Thanks!