简体   繁体   中英

insert c# code inside javascript

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() {

这将正常工作,但仅在ASPX文件中有效。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM