2016-07-30 3 views
0

"htmlAttributes"및 "routeValues"(템플릿의 일부로 필요한 것 같군요 ??) 아래의 링크를 추가하는 방법html.action. 클래스 추가 및 routevalues ​​및 htmlattributes

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

가 나는 행운으로 다음과 같은 시도 :

<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" }. new { @class = "btn navbar-btn js-login-btn" })</li> 

답변

2

당신은 모든 HTML은 하나의 annonymous 객체에 속성을 넣어 과부하의 5 번째 매개 변수로 사용하는 것을 전달할 수 있습니다.

이 자세한 답변을 완벽하게 일했다

@Html.ActionLink("Register", "Register", "Account",routeValues: null, 
     htmlAttributes: new { id = "registerLink" , @class = "btn navbar-btn js-login-btn" }) 
+0

, 덕분에 작동합니다 – Gavin5511