Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C++

jQuery 3D Content Image Slider in ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
9 Feb 2015CPOL 15.3K   3   1
jQuery 3D Content Image Slider in ASP.NET MVC

In this article, we will create a Responsive jQuery 3D Content Image Slider in ASP.NET MVC using Adaptor.

You can find the plugin here.

Adaptor content slider aims to provide a simple interface for developers to create cool 2D or 3D slide animation transitions.

You can download the plugin from Github.

Implementation

Create a new project in ASP.NET MVC named JQueryImageSlider.

After that, copy the CSS, img, js folders and paste in JQueryImageSlider project.

Image 1

jquery image slider 3d

Image 2

jquery image 3d slider

In the _Layout.cshtml page, reference the Adaptor 3D slider files.

Image 3

jquery image slider reference files

Now create class models ImageModel that holds images from database.

C#
public class ImageModel
{
    public int ImageID { get; set; }
    public string ImageName { get; set; }
    public string ImagePath { get; set; }
}

Get the images list from the repository and bind it to slider.

C#
public ActionResult Index()
{
   //Bind it from the repository
   List imageList = new List();
   imageList.Add(new ImageModel { ImageID = 1, 
   ImageName = "Image 1", ImagePath = "/img/the-battle.jpg" });
   imageList.Add(new 
      ImageModel { ImageID = 2, 
      ImageName = "Image 2", ImagePath = "/img/hiding-the-map.jpg" 
   });
   imageList.Add(new ImageModel { ImageID = 3, 
   ImageName = "Image 3", ImagePath = "/img/theres-the-buoy.jpg" });
   imageList.Add(new ImageModel { ImageID = 4, 
   ImageName = "Image 4", ImagePath = "/img/finding-the-key.jpg" });
   imageList.Add(new ImageModel { ImageID = 5, 
   ImageName = "Image 5", ImagePath = "/img/lets-get-out-of-here.jpg"});
   return View(imageList);
}

In the View page, add the following code:

HTML
 <div id="viewport-shadow">
    <a href="#" id="prev" 
    title="go to the next slide"></a>
    <a href="#" id="next" 
    title="go to the next slide"></a>
    <div id="viewport">
        <div id="box">
            @*Bind images here*@
            @foreach (var item in Model)
            {
                <figure class="slide">
                    <img src=@item.ImagePath>
                </figure>
            }


        </div>
    </div>
    <div id="time-indicator"></div>
</div>

@* here we are binding the slider controls navigation *@
<footer>
    <nav class="slider-controls">
        <ul id="controls">
            @{int index = 0;}
            @foreach (var item in Model)
            {
                
                 string cssClass = index.Equals(0) ? 
                 "goto-slide current" : "goto-slide";

                 <li><a class="@cssClass" 
                 href=" #" data-slideindex="@index"></a></li>
                 index= index +1;
            }
          
        </ul>
    </nav>
</footer>

Adding Caption for the Slider

We can add the caption for image slider using the figcaption tag.

HTML
<figure class="slide">
    <img src=@item.ImagePath class="img-responsive">
    <figcaption>Static Caption</figcaption>
</figure>

Output

Image 4

Image Slider

Responsive Output

responsive image slider

You can download the source code from GitHub.

The post jQuery 3D Content Image Slider in ASP.NET MVC appeared first on Venkat Baggu Blog.

License

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


Written By
Software Developer (Senior) eBiz Solutions http://venkatbaggu.com/
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionChange style on load Pin
tocik19-May-15 10:32
tocik19-May-15 10:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.