Razor: Convert Dictionary from Server to Javascript Dictionary

@model IEnumerable<HD.TVAD.Features.TimePeriod.SponsorProgram.Models.SponsorProgramViewModel>

@{
    Dictionary<stringGuid> dicProgram = new Dictionary<stringGuid>();
    foreach (var temp in Model)
    {
        dicProgram.Add(temp.Name, (Guid)temp.Id);
    }
}
<script>
    var sponsorProgramDic = {};
    sponsorProgramDic = @Json.Serialize(dicProgram);
</script>

Comments

Popular posts from this blog

Cách khắc phục lỗi NodeJS chạy quá ngốn Ram trên Visual Studio 2017

Javascript: Calcuate MD5 hash of a large file