Developing Simple Image Slideshow in ASP.Net
1-Add a new web form to your projct.
2-Place this script code in ".aspx" page.
3-Create folder name it as Images,add some images with name as 1.jpg,2.jpg...
because in script -"Server" i declare a Slide[] with size-5. For this array i read images from Images folder
in a "for loop" that's why i named images as 1.jpg,2.jpg......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="slide.aspx.cs" Inherits="slide" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>SlideShow</title>
<script runat="Server" type="text/C#">
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[5];
for (int i = 0; i <= 4; i++)
{
slides[i] = new AjaxControlToolkit.Slide("Images/"+i+".jpg", "", "");
}
return (slides);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="400px" align="center" bgcolor="silver">
<tr align="center">
<td>
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<asp:Label ID="lableImageDetail" runat="server" ForeColor="#000000" />
</td>
</tr>
<tr align="center">
<td>
<asp:Image runat="server" ID="image1" Height="250" Width="300" />
</td>
</tr>
<tr align="center">
<td>
<asp:Button ID="buttonPrev" runat="Server" Text="Previous" Width="80px" />
<asp:Button ID="buttonPlay" runat="server" Text="Play" Width="80px" />
<asp:Button ID="buttonNext" runat="Server" Text="Next" Width="80px" />
</td>
</tr>
</table>
<ajaxToolkit:SlideShowExtender ID="slideShowExtender1" runat="Server"
TargetControlID="image1"
ImageDescriptionLabelID="lableImageDetail"
Loop="true"
AutoPlay="true"
StopButtonText="Stop"
PlayButtonText="Play"
NextButtonID="buttonNext"
PreviousButtonID="buttonPrev"
PlayButtonID="buttonPlay"
SlideShowServiceMethod="GetSlides" />
</form>
</body>
</html>
1-Add a new web form to your projct.
2-Place this script code in ".aspx" page.
3-Create folder name it as Images,add some images with name as 1.jpg,2.jpg...
because in script -"Server" i declare a Slide[] with size-5. For this array i read images from Images folder
in a "for loop" that's why i named images as 1.jpg,2.jpg......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="slide.aspx.cs" Inherits="slide" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>SlideShow</title>
<script runat="Server" type="text/C#">
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[5];
for (int i = 0; i <= 4; i++)
{
slides[i] = new AjaxControlToolkit.Slide("Images/"+i+".jpg", "", "");
}
return (slides);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="400px" align="center" bgcolor="silver">
<tr align="center">
<td>
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<asp:Label ID="lableImageDetail" runat="server" ForeColor="#000000" />
</td>
</tr>
<tr align="center">
<td>
<asp:Image runat="server" ID="image1" Height="250" Width="300" />
</td>
</tr>
<tr align="center">
<td>
<asp:Button ID="buttonPrev" runat="Server" Text="Previous" Width="80px" />
<asp:Button ID="buttonPlay" runat="server" Text="Play" Width="80px" />
<asp:Button ID="buttonNext" runat="Server" Text="Next" Width="80px" />
</td>
</tr>
</table>
<ajaxToolkit:SlideShowExtender ID="slideShowExtender1" runat="Server"
TargetControlID="image1"
ImageDescriptionLabelID="lableImageDetail"
Loop="true"
AutoPlay="true"
StopButtonText="Stop"
PlayButtonText="Play"
NextButtonID="buttonNext"
PreviousButtonID="buttonPrev"
PlayButtonID="buttonPlay"
SlideShowServiceMethod="GetSlides" />
</form>
</body>
</html>
No comments:
Post a Comment