James Zhou's blog

技术备忘录

ASP.NET MVC - loop model data in javascript

Key: razor syntax using @: before the js variable in c# code block

Example:

 var chartData = [];

        @for(int i=0; i < Model.ModuleDetails.Count; i++)
        {
            @: chartData.push(@Html.Raw(Json.Encode(Model.ModuleDetails[i].ChartData.ToArray())));
        }

reference:

http://stackoverflow.com/questions/2002831/asp-net-mvc-how-can-you-loop-through-model-data-in-javascript


阅读更多
个人分类: ASP.NET MVC
上一篇EF6 Database First (DbContext) - Change Schema at runtime
下一篇LINK - About Cache Control of Azure Blob Files
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭