I am trying rating in asp.net mvc4 with entity framework, I have tried this code in cshtml but it is not working, please help me to achieve this. Its working while i am running in normal browser but it is not working while integrating into the asp.net mvc4
{
<h2>rating</h2>
<form method="post" id="signin" action="@Url.Action("rating", "Rating")">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="D:\My Programs\FSLIndiaLatest\FSLIndiaLatest\Scripts\jquery.js"></script>
<script type="text/javascript" src="D:\My Programs\FSLIndiaLatest\FSLIndiaLatest\Scripts\rating.js"></script>
<link rel="stylesheet" type="text/css" href="D:\My Programs\FSLIndiaLatest\FSLIndiaLatest\Styles\rating.css" />
<script type="text/javascript">
$(function () {
$('.rating').rating();
$('.ratingEvent').rating({ rateEnd: function (v) { $('#result').text(v); } });
});
</script>
<input type="text" class="ratingEvent rating9" value="5" />
<div><b id="result">5</b> start(s)</div>
<p> </p>
</form>
}
code for rating.js {
(function ($)
{
$.fn.rating = function (options)
{
var settings = $.extend(
{
rateEnd: function (value) { }
}, options);
function setRating(e, ul)
{
var i = parseInt(e.val());
if (!i) { i = 0; }
ul.find('a').removeAttr('class');
ul.find('a:lt(' + i + ')').attr('class', 'full');
}
this.each(function ()
{
var e = $(this);
var c = parseInt(e.attr("class").match(/rating\d+/)[0].replace('rating', ''));
var ul = $('<ul class="rating"></ul>').insertAfter(e).width(c * 20 + 'px');
if (c > 0)
{
for (k = 0; k < c; k++)
{
ul.append('<li><a href="javascript:void(0);" title="' + (k + 1) + '">' + (k + 1) + '</a></li>')
}
}
if (e.prop('readonly'))
{
var i = parseInt(e.val());
if (!i) { i = 0; }
ul.find('a').attr('title', i + ' / ' + c);
}
else
{
ul.find('a').each(function (index, link)
{
var link = $(link);
link.hover(function ()
{
ul.find('a').removeAttr('class');
ul.find('a:lt(' + (index + 1) + ')').attr('class', 'hover');
}, function ()
{
setRating(e, ul);
});
link.click(function ()
{
e.val(index + 1);
setRating(e, ul);
settings.rateEnd(index + 1);
});
});
}
setRating(e, ul);
e.hide();
});
return this;
}
})(jQuery);
}
code for rating.css
{
.rating { height: 20px; padding:0px; margin:0px; }
.rating li { list-style: none; float: left; width: 20px; height: 20px; padding:0px; margin:0px;}
.rating li a { display: block; width: 20px; height: 20px; padding:0px; margin:0px; overflow: hidden; text-indent: -100px; background-image: url(D:\My Programs\FSLIndiaLatest\FSLIndiaLatest\Images\rating.png); background-repeat: no-repeat; text-decoration:none; }
.rating li a:hover { background-color: transparent; text-decoration: none; }
.rating li .hover { background-position: 0px -20px; }
.rating li .full { background-position: 0px -40px; }
}