c# - MVC Url.Content with javascript local variable -
i have problem this:
var id=5; var el = $("mainphotoholder"); el.attr("src", '@url.content("~/page/getimage/" + id)');
id local javascript variable, gives me error saying not in context. question how point out should javascript variable , not c# 1 ...?
you cannot mix javascript , razor in way. razor not have reference cannot use generate link. try this:
el.attr("src", '@url.content("~/page/getimage/")' + id);
you might have use "url.action" if you're serving images controller rather static repository.
Comments
Post a Comment