connectseekers.com

Wednesday, 9 March 2016

Magnifying Glass Effect Of Image Using jQuery in MVC

3/09/2016 - By Pranav Singh 2

This article will show you how you can perform magnifying glass effect of image using jquery in mvc. In this article I have used jZoom jQuery plugin.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcApplication1.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            ViewBag.ImageURL = "../../Images/p.jpg";
            return View();
        }
    }
}

In above code I have used viewbag to store the image url. Now create the view and add the below library reference.


<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="../../Content/jzoom.min.js" type="text/javascript"></script>


Now we will add the below jquery code. This code will perform the zoom effect.


<script>
    $('.jzoom').jzoom({ bgColor: "#222" });
</script>


Now check the complete code.


@{
    ViewBag.Title = "Magnifying Glass Effect Of Image Using jQuery in MVC";
}
<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="../../Content/jzoom.min.js" type="text/javascript"></script>
<script>
    $('.jzoom').jzoom({ bgColor: "#222" });
</script>
<style>
    img
    {
        border: 3px solid #fff;
    }
    .jzoom
    {
        position: absolute;
        top: 10px;
        left: 5px;
        width: 350px;
        height: 350px;
    }
</style>
<div class="jzoom">
    <img src="@ViewBag.ImageURL" height="350" width="350">
</div>


Here we need to pass only the small image name, and big image name will be the prefix with _big.
Now we have done run the application and check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

2 comments:

  1. could put the example in asp.net with vb.net. thank you

    ReplyDelete
    Replies
    1. Hi Please use C# to VB converter to convert the code in VB.Net
      https://converter.telerik.com/

      OR check the converted code.

      Imports System
      Imports System.Collections.Generic
      Imports System.Linq
      Imports System.Web
      Imports System.Web.Mvc

      Namespace MvcApplication1.Controllers
      Public Class HomeController
      Inherits Controller

      Public Function Index() As ActionResult
      ViewBag.ImageURL = "../../Images/p.jpg"
      Return View()
      End Function
      End Class
      End Namespace

      Delete

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top