1

Greetings, how can I inject c# code (my Model property) inside javascript? I want to do something like this:

$(".star<%=Model.ROWGUID %>").mouseover(function() {
    var span = $(this).parent("span");
    var newRating = $(this).attr("value");
    setRating(span, newRating);
});

This works fine for single view. But when I Render PartialView in loops it causes the problem. Even alert("test") in mouseover event is not executed

EDIT Ok, I figured out where the problem was. This was missing:

 $(document).ready(function() {
3
  • 1
    That should work, as far as I can tell. What problem are you facing ? Commented Apr 23, 2010 at 22:21
  • Is this a asp.net application? Commented Apr 23, 2010 at 22:21
  • yes, this is an asp.net mvc application Commented Apr 23, 2010 at 22:41

1 Answer 1

3

This will work fine, but only in an ASPX file.

Sign up to request clarification or add additional context in comments.

1 Comment

I recommend to do it on Render

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.