Using "data-toggle" with Html.ActionLink

nermik picture nermik · Oct 19, 2012 · Viewed 38.7k times · Source

I want to use "data-toggle" wiht actionLink. Like this;

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

Unfortunately, doesn't accept. How can i use "data-toggle" like standart links?

Answer

Nickvda picture Nickvda · Jan 28, 2013

You can't. But there is a simple work-around. What you do is, replace the - with a _. During runtime it will get converted to a dash (-). So;

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