I'm starting to learn ASP.NET MVC, and have a problem, how generate code with Html.ActionLink
like this:
<a href="~/Views/Home/Create.cshtml" class="btn btn-primary">
<i class="icon-pencil icon-white"></i>
<span>
<strong>Create</strong>
</span>
</a>
please.
Html.ActionLink()
only supports plain-text links.You should use
<a href="@Url.Action(...)">
for more-complex links.I wanted to add to SLaks answer.
Using
<a href="@Url.Action(...)">
with what user2567619 wanted.I think it's worth mentioning that
@Url.Action
can take it's parameters like this:Whereas
@Html.ActionLink
can take it's parameters like this:It may be pretty obvious, but I thought it was worth noting.
Edit
As Peck_conyon noted, for both
@Url.Action
and@Html.ActionLink
, these are just one of the ten different overload methods.For documentation on
UrlHelper.Action
, look here.For documentation on
LinkEtensions.ActionLink
, look here.Result
If it's in the Layout page, you can use this, I think it may help:
or like this for a action_link:
Hope this helps.
Simple as this: