MVC @ Html.ActionLink with Name

Nat*_*Pet 3 asp.net-mvc razor asp.net-mvc-3

我有以下内容

@Html.ActionLink("Edit", "EditProg", new { id = item.ID }) 
Run Code Online (Sandbox Code Playgroud)

我想知道如何提供上面的名称,因为我需要在提交之前捕获此名称.有类似的东西name = "EditLink"吗?

Dar*_*rov 5

你的意思是name在锚点上添加一个属性(即使这个属性在锚点上无效)?

@Html.ActionLink(
    "Edit",                        // linkText
    "EditProg",                    // actionName
    new { id = item.ID },          // routeValues
    new { name = "EditLink" }      // htmlAttributes
)
Run Code Online (Sandbox Code Playgroud)

或者将其作为查询字符串参数发送给控制器?

@Html.ActionLink(
    "Edit",                 // linkName
    "EditProg",             // actionName
    new {                   // routeValues
        id = item.ID, 
        name = "some name" 
    }
)
Run Code Online (Sandbox Code Playgroud)