Click here to Skip to main content
15,997,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new asp .net. Suppose I have 10 images and i using image tag to display a single image at one time. I want to change the picture after every 10 secounds. So i am using a update panel and timer but it is not working properly. Anybody can tell me how i can do this.
Thanks
dEV kASHYAP
Posted
Comments
uspatel 16-Feb-12 2:49am    
share code....

1 solution

XML
<script src="../jquery-1.4.min.js" type="text/javascript"></script>



<div id="slider" style="width:200px;">

    <p>jQuery Slide show</p>

    <img id="img1" src="../images/aspnet4.gif" />

</div>

<script language="javascript" type="text/javascript">

var interval = 3000; // Line 1: time interval after which next image will load



var images = ['../images/aspnet4.gif', '../images/aspnet4css.gif', '../images/jquerycourse.gif']; // Line 2



var i = 1; // Line 3: default index of the image from the array that will be shown by default



setInterval(ChangeImages, interval); // Line 4: timer that will run after every interval



// function that will change the images

function ChangeImages() {

    if (i == images.length) { i = 0; }


    $("#img1").slideUp('slow', function () {$(this).attr('src', images[i]); i++; }).slideDown('slow');

}

</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900