I am attempting to render an address from my model. The string contains line breaks that I am replacing with a break tag. Although, it is rendering on the page as a string instead as HTML. How can I force my string to render as HTML instead?
Attempt:
<span id="addressLine"> @Model.MyData.Address.Replace(" ", "<br />"); </span>
Result on page:
Address Top<br />Street Name<br />City<br />PostCode
Should be displayed as:
Address Top Street Name City PostCode
Use @Html.Raw(Model.MyData.Address.Replace(" ", "<br />"))
@Html.Raw(Model.MyData.Address.Replace(" ", "<br />"))
2.1m questions
2.1m answers
60 comments
57.0k users