I am just starting with mvc3 and razor having done some mvc2 in the past and something puzzles me.
I am trying to render a unordered list from a collection in my model and have done so successfully. using this code.
In my view:
@using (Html.BeginForm())
{
<ul>
@Html.DisplayFor( m => m.SomeThings)
</ul>
}
In my DisplayTemplate:
@model MyNamespace.Models.SomeType
<li>
<a href="@Url.Content(String.Format("~/SomeUrl/{0}", @Html.DisplayFor(x => x.UrlText)))">@Html.DisplayFor(x => x.Name)</a>
</li>
This all works and is fine but I've noticed that the display template fails XHTML 1.0 Transitional validation and thus generates a warning (Element 'li' cannot be nested within element li') this is annoying as its not nested but is there anyway to stop this error ? Or is it something i must put up with ?
Code looks fine to me, I've noticed also that the templates try to get validated, I learned to live with it, resharper reports that everything is ok but just shoes a green hint rather than an error, since it is trying to validate something as XHTML which is not then you are ok to leave it.