I have a model, which has a few regular properties like strings
and integers
, and it also have 2 ilist(of string)
properties.
I made a DisplayTemplate
for these that looks like this and is called ListOfString.vbhtml
:
@ModelType List(Of String)
@If Model IsNot nothing And Model.Any Then
@<ul>
@For i As Integer = 0 To Model.Count
@<li>@Html.Raw(Model(i))</li>
Next
</ul>
end if
This is how the properties are decorated:
<UIHint("ListOfString")>
<Display(Name:="Options", ResourceType:=GetType(WebText))>
Public Property Options As List(Of String) = New List(Of String)
Then, in my view, I am calling @Html.DisplayForModel()
. Expecting all my properties to be written out by the default Display templates, and my custom one for the lists for the properties that are lists.
All the properties that are not IList(of string)
are rendered out fine (it's ugly, but that is a separate problem all together).
I tried having the Display Template in the Views/Shared/DisplayTemplates
folder in the project base, and in the Area/Views/controllername/DisplayTemplates
folder and neither work.
The lists DO have values in them, and the templates are not being rendered because I put plain "hello" in them and it did not show up. So it isn't a case of model binding going wrong.
Am I completely off my rocker in expecting this to work? I was under the impression that this was one of the great things about display templates and whatnot.