2012-10-19 13 views
27

Desidero utilizzare "data-toggle" con actionLink. Come questo;Utilizzo di "data-toggle" con Html.ActionLink

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

Purtroppo, non accetta. Come posso usare "data-toggle" come collegamenti standard?

risposta

65

Non è possibile. Ma c'è un semplice work-around. Quello che fai è, sostituire il - con un _. Durante il runtime verrà convertito in un trattino (-). Quindi;

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

Come funziona? È un comportamento predefinito di ASP.Net MVC? –

+0

Sì :) MVC 3,5 almeno. – Nickvda

+1

Sì, ha funzionato per me, grazie –

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