Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:08:13+00:00 2026-06-15T11:08:13+00:00

I am trying to implement the image crop feature for my MVC application. I

  • 0

I am trying to implement the image crop feature for my MVC application.

I am following this tutorial: http://www.askamoeba.com/Opensource/Opensourcedetail/132/Crop-Resize-Upload-Images-in-C-MVC3-MVC4-using-Jquery-Razor

I am using this library: http://deepliquid.com/content/Jcrop.html

I am new to JQuery with MVC and Razor.

For some reason this JQuery is not even registering:

@{
    ViewBag.Title = "Avatar Editor Page";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model SimsTemplate.Models.ViewModels.AvatarEditorModel

<script type="text/javascript">

    $(function() {
     jQuery('#avatarImageEditor').Jcrop({
        onChange: showPreview,
        onSelect: showPreview,
        setSelect: [@Model.Top, @Model.Left, @Model.Right, @Model.Bottom],
        aspectRatio: 1
    });
 });

function showPreview(coords)  {
     if (parseInt(coords.w) > 0)  {
         $('#Top').val(coords.y);
         $('#Left').val(coords.x);
         $('#Bottom').val(coords.y2);
         $('#Right').val(coords.x2);

         var width = @Model.Width;
         var height = @Model.Height;
         var rx = 100 / coords.w;
         var ry = 100 / coords.h;

         jQuery('#preview').css({
             width: Math.round(rx * width) + 'px',
             height: Math.round(ry * height) + 'px',
             marginLeft: '-' + Math.round(rx * coords.x) + 'px',
             marginTop: '-' + Math.round(ry * coords.y) + 'px'
         });
     }
}

</script>

 <div id="cropContainer">

     <div id="cropPreview">
     Preview:
        <img src="@Model.Avatar.ImageUrl" id="preview" alt="" />
    </div>

 <div id="cropDisplay">
 Display:
     <img src="@Model.Avatar.ImageUrl" id="avatarImageEditor" alt="" />
</div>

<input id="Top" name="Top" type ="text"/>
<input id="Bottom" name="Top" type ="text"/>
<input id="Left" name="Top" type ="text"/>
<input id="Right" name="Top" type ="text"/>

</div>

<div id="mainform">

@using (Html.BeginForm("Edit", "Avatar", FormMethod.Post))
{
    @Html.DisplayFor(x => x.Avatar.ImageUrl)         
    @Html.HiddenFor(x => x.Left)
    @Html.HiddenFor(x => x.Right)
    @Html.HiddenFor(x => x.Top)
    @Html.HiddenFor(x => x.Bottom)
    @Html.HiddenFor(x => x.Avatar.ImageUrl)
    <input type='submit' name='action' value='Crop' />
}
</div>

I have the view models and controller set up correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:08:14+00:00Added an answer on June 15, 2026 at 11:08 am

    You must

    Close (div id=”mainform”)

    Adding: in the edit view

    @{
        @Scripts.Render("~/bundles/jquery")
        <script src="@Url.Content("~/Scripts/JCrop/jquery.Jcrop.js")" type="text/javascript"></script>
        <link rel="stylesheet" href="@Url.Content("~/Content/JCrop/jquery.Jcrop.css")" type="text/css" />
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this tutorial: http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/ I am trying to create a simple activity that
I am trying to implement Jquery Image Bubbles as shown here: http://www.dynamicdrive.com/dynamicindex4/imagebubbles.htm However Im
Trying to implement this gallery on my website. http://coffeescripter.com/code/ad-gallery/ It is noted in the
I am trying to implement an application which uses RIOT (Radical Image Optimization Tool)
I am trying to implement the following: Please check the image here: The problem
I have been trying to implement this code , where i capture a image
http://tympanus.net/codrops/2011/09/05/slicebox-3d-image-slider/ I'm trying to implement Slicebox into my website and I'm having issues. I
I am trying to implement an application which would take an image from the
So I am trying to implement a basic image lazy load feature to speed
I am trying to implement the following background for the application... For the background

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.