vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Friday, January 6, 2012

Autoscroll slideshow using jquery in Asp.net control or slide show using Repeater or Datalist Control


Introduction

Here i share my code to create a horizontal slide show using jquery...

Description:

when u get find any jquery code they give example with only static images..But now here i get the image from the database. Also here i use asp.net control to slideshow the images.
we all store the images only in database..Then its very easy to keep and find the images..
This is auto scroll slide show for an every three seconds its will change the images smoothly..

Here i gave the jquery file with url..so you can easily download and merge the file with your project...

Also you can use data list control instead of repeater control..

Here i store only the image path in database...For yours customize store images as byte in database and retrieve bind it image control...

By using Next and Previous button you can change the images in slide show....

<link href="http://sorgalla.com/projects/jcarousel/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://sorgalla.com/projects/jcarousel/lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://sorgalla.com/projects/jcarousel/lib/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://sorgalla.com/projects/jcarousel/skins/tango/skin.css" />

<script type="text/javascript">

    function mycarousel_initCallback(carousel) {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };

    jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
                  auto: 2,
            wrap: 'last',
            initCallback: mycarousel_initCallback
        });
    });

</script>

Sample image:



        <div id="Div1">                                    <asp:Repeater ID="dlNews" runat="server">                               <HeaderTemplate>                                     
<ul id="mycarousel" class="jcarousel-skin-tango">                         </HeaderTemplate>                                                <ItemTemplate>                                                      <li>                                                         
<a href=" " title ='<%#Eval("TIT")%>'><asp:Image ID="imglst" runat="server" ImageUrl='<%#Eval("src") %>'                                
                                                                                      Width="80" Height="80" />  </a>                                             </li>                                                   </ItemTemplate>                                                  <FooterTemplate>                                                 </ul>                                            </FooterTemplate>
                                                                    </asp:Repeater>
                                                                </div>

In Code get the file bind into repeater control…



I hope you learn something useful ..post your comment here….

6 comments:

Faisal said...

It is a very good example. I need little bit help.
I need -
1. When the scrolling reach to the last item, then it will start from last to first in reverse way.
2. When the scrolling reach to the first item,
then it will start from first to last.

vijay said...

what changes u need...

Faisal said...

Now the scrolling reach the last item then it comes again from first. It is restarting from the first again.

I need if it reach the last item, then start again from last to first item, no need to restart from the first again.

Faisal said...

Now the scrolling reach the last item then it comes again from first. It is restarting from the first again.

I need if it reach the last item, then start again from last to first item, no need to restart from the first again.

Please help me.

vijay said...

For that u have do some modification in jquery file..
In next button function..if its null its again reload from start...

Faisal said...

Thank you for your reply.

Please can specify in which place I need to modify and what?
When the scrolling will reach the last 3 item, then it will make reverse from last to first.

Please help.

Post a Comment