ActionLink htmlAttributes
Działa
<a href="@Url.Action("edit", "markets", new { id = 1 })"
data-rel="dialog" data-transition="pop" data-icon="gear" class="ui-btn-right">Edit</a>
NIE DZIAŁA-DLACZEGO?
@Html.ActionLink("Edit", "edit", "markets", new { id = 1 }, new {@class="ui-btn-right", data-icon="gear"})
Wygląda na to, że nie możesz przekazać czegoś takiego jak data-icon= "gear" do htmlAttributes?
Sugestie? 74
Author: Pavel Hlobil, 2010-11-05
3 answers
Problem polega na tym, że Twoja anonimowa właściwość obiektu data-icon
ma nieprawidłową nazwę. Właściwości C# nie mogą mieć myślników w nazwach. Można to obejść na dwa sposoby:
Użyj podkreślnika zamiast kreski (MVC automatycznie zastąpi podkreślnik kreską w emitowanym HTML):
@Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new {@class="ui-btn-right", data_icon="gear"})
Użyj przeciążenia, które bierze w słowniku:
@Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new Dictionary<string, object> { { "class", "ui-btn-right" }, { "data-icon", "gear" } });
179
Author: marcind,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-05 22:35:14
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-05 22:35:14
Zastąp żądany myślnik podkreślnikiem; zostanie on automatycznie renderowany jako myślnik:
@Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new {@class="ui-btn-right", data_icon="gear"})
Staje się:
<form action="markets/Edit/1" class="ui-btn-right" data-icon="gear" .../>
24
Author: hemp,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-12-22 06:50:52
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-12-22 06:50:52
@Html.ActionLink("display name", "action", "Contorller"
new { id = 1 },Html Attribute=new {Attribute1="value"})
-5
Author: amirhossein fallahmanesh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-18 07:39:58
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-18 07:39:58