Ric*_*d77 4 asp.net-mvc model-binding
我在页面上有这个链接
<% = Html.ActionLink(item.Title, "Edit", "ArticleManagement",
new { id = item.ArticleDataID })%>
Run Code Online (Sandbox Code Playgroud)
以及接收文章Id的简单方法
public ActionResult Edit(int id)
{
//Do something
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我收到一个错误" 参数字典包含int32的参数id的空值,用于编辑(Int32)... "
当我查看Url时,我看到类似" http:// localhost:59786/ArticleManagement/Edit?Length = 17 "的内容
什么是" 长度= 17 "?那里有什么?无论如何,到目前为止,我正在使用一个只有3个项目的集合.
谢谢你的帮助
Cas*_*nge 13
您需要添加null作为最后一个参数:
<%=Html.ActionLink("Title", "Edit", "ArticleManagement",
new { id = 1 }, new { @class = "link-class", attr = "attribute value" })%>
Run Code Online (Sandbox Code Playgroud)
我认为它使用路由值作为没有null的html属性.
| 归档时间: |
|
| 查看次数: |
10318 次 |
| 最近记录: |