ASP.NET MVC: is it possible to have multiple display patterns for a type?

I have two views that show roughly the same data, but one by the client and the other by the project. This would usually be great, since the same display template was used again in both views. However, I need these elements to be different when they are listed by the client and the project. However, they already have display templates. Is there a way for me to have two display patterns for the same type?

change

Well, I forgot one important detail that makes this more complicated. Although there are separate models (view models) that contain elements for each view, the elements themselves are of mixed types (common base class). Display templates are designed for each of the types of elements that may be in the list, so I cannot use the attribute for the model.

I believe that I could make separate submodels for transferring or replacing classes, but this is more duplication and work than I would prefer.

+3
source share
1 answer

Does each view have its own strictly typed view? If so, create two different templates, then refer to them in each model with the [UIHint] annotation.

Example:

public class ClientModel
{
     [UIHint("ClientDisplay")]
     public SharedDataModel sharedData { get; set;}
     //Other fields below
}

Project. , .

, , , , , .

+6

Source: https://habr.com/ru/post/1772584/


All Articles