How do i include mvc3 razor variable in javascript?
My Code:
&开发者_Python百科lt;script type="text/javascript">
var root = @Url.Content("~/Content/");
</script>
This has no effect.
<script type="text/javascript">
var root = '@Url.Content("~/Content/WebApp/img/")';
</script>
Solution.
The first code sample is missing a pair of single or double quotes. The second one is ok. It works for me.
Or what do you mean by "This has no effect."? Have you looked at the generated HTML code? What do you get?
精彩评论