Jquery in Asp.Net

Jquery is now making a sense in the web development , Because of its features
like fast, small, and feature-rich JavaScript library
everyone is going to have It In their own websites ,So today i will explain how to integrate the Jquery in asp.net web site

Step 1
Download the Latest version of min file of jquery from this link

Step 2

Create a web page and add the references of js file in head tag of aspx page

<head runat="server">
    <title>Jquery in Action</title>
    <script src="slideshow/js/jquery-1.3.1.min.js" type="text/javascript"></script>

</head>


Step 3

Create one Function in script tag with following steps

 <script type="text/javascript">

        $(document).ready(function () {

            //Execute the slideShow
            slideShow();

        });

</script>


Step 4 Now we need to create one slideshow function script tag

function slideShow() {

            //Set the opacity of all images to 0
            $('#gallery a').css({ opacity: 0.0 });

            //Get the first image and display it (set it to full opacity)
            $('#gallery a:first').css({ opacity: 1.0 });

            //Set the caption background to semi-transparent
            $('#gallery .caption').css({ opacity: 0.7 });

            //Resize the width of the caption according to the image width
            $('#gallery .caption').css({ width: $('#gallery a').find('img').css('width') });

            //Get the caption of the first image from REL attribute and display it
            $('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
.animate({ opacity: 0.7 }, 400);

            //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
            setInterval('gallery()', 6000);

        }

        function gallery() {

            //if no IMGs have the show class, grab the first image
            var current = ($('#gallery a.show') ? $('#gallery a.show') : $('#gallery a:first'));

            //Get next image, if it reached the end of the slideshow, rotate it back to the first image
            var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#gallery a:first') : current.next()) : $('#gallery a:first'));

            //Get next image caption
            var caption = next.find('img').attr('rel');

            //Set the fade in effect for the next image, show class has higher z-index
            next.css({ opacity: 0.0 })
.addClass('show')
.animate({ opacity: 1.0 }, 1000);

            //Hide the current image
            current.animate({ opacity: 0.0 }, 1000)
.removeClass('show');

            //Set the opacity to 0 and height to 1px
            $('#gallery .caption').animate({ opacity: 0.0 }, { queue: false, duration: 0 }).animate({ height: '1px' }, { queue: true, duration: 300 });

            //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
            $('#gallery .caption').animate({ opacity: 0.7 }, 100).animate({ height: '100px' }, 500);

            //Display the content
            $('#gallery .content').html(caption);


        }


Step 5
Create a folder in root directory of your solution called 'images' and store some beautiful images in it.

Step 6

Now in Body tag create a div with as follows

<div id="gallery">
    <a href="#" class="show">
        <img src="slideshow/images/flowing-rock.jpg" alt="Flowing Rock" width="580" height="360"
            title="" alt="" rel="<h3>Flowing Rock</h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " />
    </a><a href="#">
        <img src="slideshow/images/grass-blades.jpg" alt="Grass Blades" width="580" height="360"
            title="" alt="" rel="<h3>Grass Blades</h3>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " />
    </a><a href="#">
        <img src="slideshow/images/ladybug.jpg" alt="Ladybug" width="580" height="360" title=""
            alt="" rel="<h3>Ladybug</h3>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." />
    </a><a href="#">
        <img src="slideshow/images/lightning.jpg" alt="Lightning" width="580" height="360" title=""
            alt="" rel="<h3>Lightning</h3>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." />
    </a><a href="#">
        <img src="slideshow/images/lotus.jpg" alt="Lotus" width="580" height="360" title="" alt=""
            rel="<h3>Lotus</h3>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo." />
    </a><a href="#">
        <img src="slideshow/images/mojave.jpg" alt="Mojave" width="580" height="360" title="" alt=""
            rel="<h3>Mojave</h3>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt." />
    </a><a href="#">
        <img src="slideshow/images/pier.jpg" alt="Pier" width="580" height="360" title="" alt=""
            rel="<h3>Pier</h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
    </a><a href="#">
        <img src="slideshow/images/sea-mist.jpg" alt="Sea Mist" width="580" height="360" title=""
            alt="" rel="<h3>Sea Mist</h3>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." />
    </a><a href="#">
        <img src="slideshow/images/stones.jpg" alt="Stone" width="580" height="360" title="" alt=""
            rel="<h3>Stone</h3>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." />
    </a>
    <div class="caption">
        <div class="content">
        </div>
    </div>


Step 7

Now Implement some styling for your div tag

<style type="text/css">
        body
        {
            font-family: arial;
        }
        
        .clear
        {
            clear: both;
        }
        
        #gallery
        {
            position: relative;
            height: 360px;
        }
        #gallery a
        {
            float: left;
            position: absolute;
        }
        
        #gallery a img
        {
            border: none;
        }
        
        #gallery a.show
        {
            z-index: 500;
        }
        
        #gallery .caption
        {
            z-index: 600;
            background-color: #000;
            color: #ffffff;
            height: 100px;
            width: 100%;
            position: absolute;
            bottom: 0;
        }
        
        #gallery .caption .content
        {
            margin: 5px;
        }
        
        #gallery .caption .content h3
        {
            margin: 0;
            padding: 0;
            color: #1DCCEF;
        }
    </style>


Output with Rolling Images




Happy Programming.


Comments

Anonymous said…
thanks........