0

I have the next line in my javascript file:

"<img alt=\"Active\" src=\"@Url.Content(\"~/Images/play.png\")\" />"

so I tried to do what AHM suggested in this topic (@Url.Content in separate javascript file using ASPNET MVC 3 and Razor):

var ROOT = "@Url.Content(\"~/";
"<img alt=\"Active\" src=\"" + ROOT + "Images/play.png\")\" />"

but I got an error:

Reports/@Url.Content( 404 (Not Found) 

what I did wrong?

any help appreciated!

Community
  • 1
  • 1
Alon Shmiel
  • 6,333
  • 19
  • 88
  • 134

1 Answers1

1

@Url.Content is not supported in JavaScript file

In your code is wrong

var ROOT = "@Url.Content(\"~/"; <= parentheses is not closed & you donot need to escape quotes

Instead use in beginning of file

var ROOT = '@Url.Content("~/")';
haim770
  • 47,051
  • 7
  • 96
  • 126
Satpal
  • 129,808
  • 12
  • 152
  • 166