razor - ASP.NET Display Templates - No output -
i have model:
public class definitionlistmodel : list<definitionlistitemmodel> { }
then have display template (partial view) setup in displaytemplates:
@model company.product.models.definitionlistmodel <dl> @foreach (var definition in model) { html.displayfor(m => definition); } </dl>
which calls default display template because each item definitionlistitemmodel
:
@model company.product.models.definitionlistitemmodel @html.displayfor(m => m.term, "definitionterm"); @html.displayfor(m => m.description, "definitiondescription");
and definitionterm
template looks this:
@model object @{ if (model != null) { string s = model string; if (s != null) { <dt>@s</dt> } else { // other types , models used. // last resort. <dt>@model.tostring()</dt> } } }
a breakpoint placed in last template hit , view , mark-up appears run through fine, none of renders, not dl tag first template above.
why hit breakpoints not render html?
it semi-colons. seems can't call html.displayfor
normal c# method semi-colon terminator.
for example, here's revised definitionlistmodel
template:
@model acmeco.hudson.models.definitionlistmodel @if (model != null) { <dl> @foreach (var definition in model) { @html.displayfor(m => definition) } </dl> }
note bizarre use of @
within code block that's c#. assume there's proper way displayfor
within c# block don't know is.
Comments
Post a Comment