2012-10-19 8 views
27

actionLink와 함께 "data-toggle"을 사용하고 싶습니다. 이것 같이;Html.ActionLink에서 "data-toggle"사용

Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert", data-toggle="modal" }) 

불행히도 허용하지 않습니다. 어떻게 스탠다드 링크처럼 "데이터 토글"을 사용할 수 있습니까?

답변

65

수 없습니다. 그러나 간단한 해결 방법이 있습니다. 당신이하는 일은 -를 _로 대체하십시오. 런타임 중에는 대시 (-)로 변환됩니다. 그래서;

Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert", data_toggle="modal" }) 
+1

어떻게 작동합니까? 이것은 ASP.Net MVC의 기본 동작입니까? –

+0

예 :) MVC 3,5 이상. – Nickvda

+1

예, 저를 위해 일했습니다. 고마워요. –

3
 @Html.ActionLink("TextLink", "ActionName", new { id = id }, new { @class = "btn btn-primary", data_toggle = "modal", data_target="#exampleModal" })