I used a function to construct an image path dynamically like this:
function () {
var name = $(this).attr('id') + '_o';
var newsrc = '../../Content/HomePage/' + name + '.png';
And I want to assign the newsrc using Razor Url.Content to an image tag as its source. SO, I wish to do something like this:
$(this).attr('src', '@Url.Content(newsrc)');
But VS show me red line saying that the newsrc is not exist within current context.. How can I use a variable along with Url.Content?
(Note: I am using this inside script tag...)
EDIT: An idea comes to my mind, perhaps the backdoor will be passing the newsrc to controller, use Url.Content there to resolve the url and pass it back? Is it feasible?
Any help will be appreciated..