我很困惑为什么这个代码
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从何而来?
当前回答
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" }, new { })
这将承担过载: 字符串linkText,字符串actionName,字符串controllerName,对象路由值,对象htmlAttributes
其他回答
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" }, new { })
这将承担过载: 字符串linkText,字符串actionName,字符串controllerName,对象路由值,对象htmlAttributes
只需删除“Home”(控制器的名称),这样代码将是:
Html.ActionLink("About", "About", new { hidefocus = "hidefocus" })
你忘记添加HTMLAttributes parm。
这将在没有任何更改的情况下工作:
Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" },null)
也许其他人也有同样的问题,需要通过HTMLAttributes parm提供一个类值。 以下是我的解决方案:
@Html。ActionLink("About", "About", new {controller = "Home", area = ""}, new {hidefocus = "hidefocus", @class = "nav-item nav-link"})
请使用五(5)个参数的正确重载方法。例子:
@using (@Ajax.BeginForm("Register", "Account", null,
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure",
OnBegin = "OnBegin",
OnComplete = "OnComplete"
}, new { @class = "form-login" }))