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

后端 未结 3 1527
有刺的猬
有刺的猬 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 06:21

    Hmm, this is a tricky one since the HtmlHelper.EditorFor method uses the generic parameter of the HtmlHelper to figure out which validation attributes are required.

    I would suggest writing your own EditorFor extension method that delegates calls to the non-generic HtmlHelper.Editor method.

提交回复
热议问题