MVC Display Template for Generic Type

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-12-25T22:27:05Z Indexed on 2010/12/26 17:54 UTC
Read the original article Hit count: 169

Filed under:
|
|
|

I am trying to use the model ListModel as a generic list model. I would like to enter on the page

@Html.DisplayForModel()

However the MVC is not correctly finding the templated file "ListModel.cshtml". It must work differently for generic models. What should I name the templated file in order for it to correctly be located?

public class ListModel<T>
{
public IEnumerable<T> Models {get;set;}
public string NextPage {get;set;}
}

I would expect it to look for "Shared/DisplayTemplates/ListModel.ascx" but it doesn't. Does anyone know?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET