【发布时间】:2014-03-20 15:32:21
【问题描述】:
我收到一个错误,但该错误仅显示我的页面标题;当我尝试调试并单步执行代码时,它会进入共享的 layout.cshtml 页面,但它会一直执行,并且在页脚(只有测试和图像)上失败。我试过注释掉页脚及其元素,但没有奏效。使用 chrome/firefox 中的开发工具,我似乎也找不到任何东西。
关于我哪里出错的任何提示?
这个 index.cshtml 页面最初指向一个 js 文件,其中为数据定义了一个布局。我将布局留在那里,但是当它进入索引时,它会将其重定向到列表。难道是索引中的js文件导致错误?我试过把它注释掉,但是页面是空白的。
index.cshtml 如下所示:
@{
ViewBag.Title = "People";
}
@section Head {
@Html.ScriptFile("modules/people.js", false)
}
<div class="header"><span class="name">@ViewBag.Title</span></div>
<table class="data"></table>
people.js 文件有这个:
$(function () {
if ($("#ID").length) {
init();
} else {
initializeTable("disclosures/listing", undefined, [
{ "sTitle": "ID" },
{ "sTitle": "Name" },
{ "sTitle": "Job Title" },
{ "sTitle": "Interview Complete?" },
{ "sTitle": "Completed On" },
{ "sTitle": "Last Update" }
], [
{ "name": "Completed: ", "column": 3 }
]);
}
});
我的控制器中有一个对象数组(基本上是字符串):
List<PersonStatus> people = new List<PersonStatus>();
将项目添加到列表后,我将其传递给我的视图:
return View("Listing", people);
然后在列表视图中将数组显示为表格:
@model List<PersonStatus>
@{
ViewBag.Title = "People";
}
@section Head {
@Html.ScriptFile("modules/people.js", false)
}
<div class="header"><span class="name">@ViewBag.Title</span></div>
<div class="overflow">
@if (people == null)
{
<table>
<tr>
<td>
<i><font color="#cc0000">Information not available.</font></i>
</td>
</tr>
</table>
}
@if (people != null)
{
<table class="data">
<thead>
<tr>
<th>IDNumber</th>
<th>Name</th>
<th>Job Title</th>
<th>Interview Complete?</th>
<th>Last Updated On</th>
</tr>
</thead>
<tbody>
@foreach (var p in Model)
{
var person = p;
<tr>
<td>
<th>@people.IDNumber</th>
<th>@people.Name</th>
<th>@people.JTitle</th>
<th>@people.InterviewComplete</th>
<th>@people.LastUpdateDate</th>
</td>
</tr>
}
</tbody>
</table>
}
【问题讨论】:
标签: c# javascript json visual-studio-2010 asp.net-mvc-3