Nate
Nate

Reputation: 355

Html.ActionLink() not displaying correctly

I am working with visual studio building a bookstore website for a class project and I am having trouble getting my strings to encode.

I basically print out the link to the details of a specific book

@Html.ActionLink(@Html.DisplayFor(modelItem => item.Title).ToString(), "Details", new { id = item.BookID })

With the title of the book (which is pulled straight from the database) contained as a parameter that is supposed to be displayed text.

@Html.DisplayFor(modelItem => item.Title).ToString()

But the issue is my output on the front end looks like this

This is my output

How do I overcome this?

I have tried decoding to bytes then re-encoding, but to no avail.

Any help would be appreciated!

Thanks!

Upvotes: 0

Views: 298

Answers (2)

alejosoft
alejosoft

Reputation: 186

What do you get when you do this?

@Html.ActionLink(item.Title, "Details", new { id = item.BookID })

Upvotes: 2

overflowed
overflowed

Reputation: 1838

Change the property of your Title to return a HtmlString since your titles appear to be already html encoded.

Upvotes: 0

Related Questions