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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -