开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜