Search code examples
htmlasp.netline-breakshtml-encode

line break within Html.Encode & String.Join


I have the following line of code.

<%= Html.Encode(string.Join(", ", item.company1.companies.Select(x => x.company_name).ToArray())) %>

Would it be possible to somehow replace the comma with a line break?


Solution

  • I got it.

    <%= Html.Encode(string.Join("***", item.company1.companies.Select(x => x.company_name).ToArray())).Replace("***", "<br />") %>