我的模型使用的模型是这样的:Asp.net MVC3如何在JavaScript
public class ViewMessageFileModel
{
[Display(Name = "FileOptionId")]
public int ? FileOptionId { get; set; }
[Display(Name = "LeaveInMyInbox")]
public bool ? LeaveInMyInbox { get; set; }
IList<int> _fileforMyTeam;
public IList<int> FileForMyTeam
{
get
{
if (_fileforMyTeam == null) _fileforMyTeam = new List<int>();
return _fileforMyTeam;
}
set { this._fileforMyTeam = value; }
}
IList<int> _fileforfacility;
public IList<int> FileForFacility
{
get
{
if (_fileforfacility == null) _fileforfacility = new List<int>();
return _fileforfacility;
}
set { this._fileforfacility = value; }
}
//Similarly for other option
private IList<ViewUserGroupModel> _careTeam;
public IList<ViewUserGroupModel> CareTeamForFile
{
get
{
if (_careTeam == null) _careTeam = new List<ViewUserGroupModel>();
return _careTeam;
}
set { this._careTeam = value; }
}
}
我想作为保健careteamforfile列表
1 - 使用直接如下使用在我看来,这种模式鉴于通过@ Model.CareTeamForFile 迭代。但我想用Fileforfacility和fileformyteam列表以JSON变量来保存视图在此基础上的,我必须选择或取消选择一些复选框
值这可能对我来说,转换模型elem在浏览页面上浏览json。 也建议我最好的方法。
我要转换的JSON Model.Fileforfacility在视图中,如果我使用相同的模型=“@ Html.Raw(Json.Encode(Model.FileForFacility))”; alert(model [0])它没有给int值保存 – 2013-04-06 19:02:22
你需要在使用它之前解析JSON,否则它只是一个字符串var parsed = JSON.parse(model); – 2013-04-07 03:03:33