Model inheritance possible when using strongly-typed view in MVC3?

后端 未结 3 1526
有刺的猬
有刺的猬 2020-12-10 05:46

I have the following setup in my model:

namespace QuickTest.Models
{
    public class Person
    {
        [Required]
        [Display(Name = \"Full name\")]         


        
3条回答
  •  我在风中等你
    2020-12-10 06:31

    Have you considered creating your own EditorTemplate for Person, Sender and Receiver? The EditorFor and DisplayFor look for a custom template that match the type of the object.

    The internal method will look for a template that matches the type of the object. It will then look for a template that matches the base class and then on up the chain of inheritance.

提交回复
热议问题