How to render plain HTML links in Asp.Net MVC loop?
Posted
by Joannes Vermorel
on Stack Overflow
See other posts from Stack Overflow
or by Joannes Vermorel
Published on 2009-10-26T13:12:49Z
Indexed on
2010/03/25
2:23 UTC
Read the original article
Hit count: 618
asp.net-mvc
|hyperlink
I would like to render a list of HTML links in ASP.NET MVC. Note that the links are absolute and external to the website being designed. The following code works:
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.Encode(item.Id) %>
</td>
<td>
<%= String.Format("<a href=\"{0}\">link</a>", item.Url) %>
</td>
</tr>
<% } %>
But I am wondering if it's really the right approach. Am I missing some obvious MVC control here?
© Stack Overflow or respective owner