2015-10-17 40 views
5

如何從引導按鈕調用「註冊」ActionLink(在使用VS2013的標準MVC5 項目上生成的那個)?從按鈕調用Html.ActionLink?

這是原來的代碼:

@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> 
+3

爲什麼你不要使用適當類的錨? @ Html.ActionLink(「Register」,「Register」,「Account」,routeValues:null,htmlAttributes:new {id =「registerLink」,@ class =「btn btn-info btn-link」})應該工作,應該visibile作爲按鈕了。 –

+0

完美。它運行良好。我upvoted。 –

回答

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

這應該做工精細...

+0

是否可以在新標籤中打開? – FrenkyB