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

c# - OpenXML hanging while writing elements -

php - regexp cyrillic filename not matches -

java - IntelliJ - No such instance method -