Razor和Javascript代码在一起

时间:2015-03-02 10:05:27

标签: javascript razor

我是asp.net mvc的新手。如何在剃须刀中编写javascript代码?

@foreach (var player in ViewBag.Players) 
    {
        <script>
              team.member=@player.Name;
        </script>
    }

1 个答案:

答案 0 :(得分:0)

将razor变量放在单引号中 -

team.member='@player.Name';