从按钮调用Html.ActionLink?

时间:2015-10-17 17:11:32

标签: html asp.net-mvc twitter-bootstrap

如何拨打"注册" ActionLink(在标准MVC5上生成的那个) 从引导按钮使用VS2013的项目?

这是原始代码:

@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })

我试过了,但显然它没有用:

<button type="button" class="btn btn-info" onclick="window.location.href('@Url.Action("Register", "Account")')">Add New User</button>

2 个答案:

答案 0 :(得分:18)

<input type="button" class="btn btn-info" value="Let's Go!" onclick="location.href='@Url.Action("Action", "Controller")'" />

这应该可以正常工作......

答案 1 :(得分:2)

@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { @class = "btn btn-primary", @role="button" })