【发布时间】:2013-07-16 08:15:59
【问题描述】:
我在How to use javascript variables in C# and vise versa 中遇到问题:我将这个Model 传递给视图:
public List<Tache> Get_List_Tache()
{
Equipe _equipe = new Equipe();
List<Tache> liste_initiale = _equipe.Get_List_tache();
return liste_initiale;
}
这是一个对象列表Tache,我想在其中使用它的三个字段Tache_description、Begin_date 和End_date。
在我的 JavaScript 代码中,我有这个功能,它工作正常:
<script>
$(document).ready(function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
theme: true,
header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},
editable: true,
events: [
@foreach (var m in Model.Get_List_Tache())
{
@:{title : @m.Tache_description , start: @m.Begin_date , end : @m.Begin_date }
}
]
});
});
</script>
数组events的值只是为了测试,我需要用Model的值填充events。对于这样的每个元素:title = Tache_description、start = Begin_date 和 end = End_date。
那么我该怎么做呢?有什么建议吗?
【问题讨论】:
-
有没有什么办法可以返回 JSON 结果,并可能以这种方式调用数据?
标签: c# javascript .net asp.net-mvc razor