谁能明白为什么这个简单的测试网站打印出一个空表(在 html 中,创建了一个包含 2 行 (tr) 的表,但没有生成单元格 (td))。
或者调试它的最佳方法是什么
调试控制器.cs...
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
namespace myproject.Controllers
{
public class type1
{
public String ipAddress;
public String connectionId;
}
public ActionResult Debug2(string arg1)
{
List<dynamic> obj1 = new List<dynamic>();
obj1.Add(new type1 {ipAddress="192.168.1.1", connectionId="123"});
obj1.Add(new type1 {ipAddress="192.168.1.2", connectionId="345"});
ViewBag.obj1 = obj1;
return View();
}
}
}
和Debug2.cshtml....
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="~/Scripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.signalR-1.1.3.js"></script>
<script type="text/javascript" src="~/signalr/hubs"></script>
@{
var grid = new WebGrid(ViewBag.obj1);
}
</head>
<body>
<div>
@grid.GetHtml()
</div>
</body>
</html>