在我的视图中使用 underscore.js,我试图将变量传递serialNumberId
回我的视图。这是我尝试过的:
<a href="@Url.Action("process", "wip", new { id = <%= serialNumberId %> })">
Text
</a>
……但它不喜欢那样。红色的波浪线。
然后我尝试了:
<a href="@Url.Action("process", "wip")/<%= serialNumberId %>">
Text
</a>
...但是代码甚至从未到达我process
在控制器中的操作方法。
如果我像这样对 serialNumberId 值进行硬编码,一切正常:
<a href="@Url.Action("process", "wip", new { id = 10 })">
Text
</a>
或像这样:
<a href="@Url.Action("process", "wip")/10">
Text
</a>
那么我该怎么做,但是用我的serialNumberId
变量呢?
编辑:这serialNumberId
是来自的代码(它是 DataTables 函数的一部分):
...
columns: [
{
data: 'serialNumberId', searchable: false, orderable: false,
render: function (data, type, row, meta) {
var structure = _.template($('#tmpl-actions').html()),
html = structure({ serialNumberId: data });
return html;
}
},
编辑2:好的,所以在玩了一些之后,我不认为这是一个下划线问题。这是一个数据表问题。serialNumberId: data
由于某种原因,上面是 Null 。当我逐步通过 ASP.Net 时,它被一个 int 填充,但是当它通过 DataTables 时它是空的。