Reputation: 3107
I have inside a view file something like
@Html.ActionLink("Details", "Details", new { id=item.RuleId }) |
@Html.ActionLink("Edit", "Edit", new { id = item.RuleId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.RuleId })
and this works, but when I change it to something like
@Html.ActionLink("Details", "Details", new { id=item.RuleId }) |
@if( something )
{
Html.ActionLink("Edit", "Edit", new { id = item.RuleId });
Html.ActionLink("Delete", "Delete", new { id = item.RuleId });
}
it stops displaying the second and third items ( although is entering the branch ) .
Any ideas why ?
Upvotes: 3
Views: 922
Reputation: 9155
Replace your code with this:
@Html.ActionLink("Details", "Details", new { id=item.RuleId }) |
@if( something )
{
@Html.ActionLink("Edit", "Edit", new { id = item.RuleId })
@Html.ActionLink("Delete", "Delete", new { id = item.RuleId })
}
Upvotes: 0
Reputation: 888177
Html.ActionLink
returns an IHtmlString
object containing an <a>
tag.
It doesn't do anything by itself.
Your code is ignoring this result, so nothing happens.
You need to print the result to the page using the @
character.
Upvotes: 10