0

I'm learning ASP.NET MVC and I can't figure out how to add a text or an image to an actionlink. I guess I need to use Html Helpers inside Html Helpers!?

This is what I'm using right now:

Images:

<img src="~/Content/Images/Categories/@Html.DisplayFor(model => item.ImageFileName)" alt="@Html.DisplayFor(model => item.Name)" />

and headlines:

<h2>@Html.DisplayFor(model => item.Name)</h2>

My goal is to insert the H2 tag inside an Action link in one row and the image tag inside another Actionlink.

I have tested all kinds of combinations of these examples, but I get red lines below text and it's not working:

@Html.ActionLink(Html.DisplayNameFor(model => item.Name).ToHtmlString(), "SortFirstName"

or this:

@Html.ActionLink("Edit Record", "Edit", new { Id = 3 })

I just want the option to click on the text inside the Headline or the Image and then get to the Controller: WebShop/ShowProducts + the Category ID

Preciate if I can get some help with this to be able to continue with my project.

front-back
  • 257
  • 1
  • 7
  • 13

0 Answers0