Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Html.ActionLink中包含模型属性的语法是什么?_C#_Html_Asp.net Mvc - Fatal编程技术网

C# 在Html.ActionLink中包含模型属性的语法是什么?

C# 在Html.ActionLink中包含模型属性的语法是什么?,c#,html,asp.net-mvc,C#,Html,Asp.net Mvc,例如,假设我在foreach中有以下代码来生成一个表。在其中一列中有一个“单击此处查看更多详细信息”类型的链接。PurchaseOrderNumber应创建指向详细信息页面的超链接,并传入PurchaseOrderNumber。示例:/Sales/Details/7000 <td> @Html.ActionLink("Details", "Index", @Html.DisplayFor(m => item.PurchaseOrderNumber))

例如,假设我在foreach中有以下代码来生成一个表。在其中一列中有一个“单击此处查看更多详细信息”类型的链接。PurchaseOrderNumber应创建指向详细信息页面的超链接,并传入PurchaseOrderNumber。示例:/Sales/Details/7000

    <td>
        @Html.ActionLink("Details", "Index", @Html.DisplayFor(m => item.PurchaseOrderNumber))
    </td>

@ActionLink(“详细信息”、“索引”、@Html.DisplayFor(m=>item.PurchaseOrderNumber))
相反,它只创建指向/Sales?Length=5的超链接


如何正确执行此操作?

假设控制器名称为
Sales
,操作名称为
Details
,参数名称为
id

@Html.ActionLink("Click here for more details",
                 "Details",
                 "Sales",
                 new { id = item.PurchaseOrderNumber }, null)

请参见

仍在为我生成与以前相同的URL的控制器名称、操作和参数名称是什么?与代码中的名称完全相同,但它只是创建了“长度=5”,不管这意味着什么。重载错误-您需要为html属性添加第5个参数-
@html.ActionLink(“单击此处查看更多详细信息”、“详细信息”、“销售”,新{id=item.PurchaseOrderNumber},空)