我很困惑为什么这个代码
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" })
此链接的结果:
<a hidefocus="hidefocus" href="/Home/About?Length=4">About</a>
隐焦部分是我的目标,但?Length=4从何而来?
我很困惑为什么这个代码
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" })
此链接的结果:
<a hidefocus="hidefocus" href="/Home/About?Length=4">About</a>
隐焦部分是我的目标,但?Length=4从何而来?
当前回答
请使用五(5)个参数的正确重载方法。例子:
@using (@Ajax.BeginForm("Register", "Account", null,
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure",
OnBegin = "OnBegin",
OnComplete = "OnComplete"
}, new { @class = "form-login" }))
其他回答
你忘记添加HTMLAttributes parm。
这将在没有任何更改的情况下工作:
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" },null)
只需删除“Home”(控制器的名称),这样代码将是:
Html.ActionLink("About", "About", new { hidefocus = "hidefocus" })
这工作得很好
@Html.ActionLink("Informationen", "About", "Home", new { area = "" }, new { @class = "nav-link" })
新增{area = ""}。
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" }, new { })
这将承担过载: 字符串linkText,字符串actionName,字符串controllerName,对象路由值,对象htmlAttributes
我解决这个问题的方法是在匿名声明(new{})之前添加一个null到第四个参数,以便它使用以下方法重载:(linkText, actionName, controllerName, routeValues, htmlAttributes):
Html.ActionLink("About", "About", "Home", null, new { hidefocus = "hidefocus" })