Asp.net mvc 3 如何跨回发维护基本类型集合中的项类型?
我有一个基类、一组子类和一个集合容器,用于使用局部视图动态创建和填充控件Asp.net mvc 3 如何跨回发维护基本类型集合中的项类型?,asp.net-mvc-3,Asp.net Mvc 3,我有一个基类、一组子类和一个集合容器,用于使用局部视图动态创建和填充控件 // base class public class SQControl { [Key] public int ID { get; set; } public string Type { get; set; } public string Question { get; set; } public string Previous { get; set; } public vi
// base class
public class SQControl
{
[Key]
public int ID { get; set; }
public string Type { get; set; }
public string Question { get; set; }
public string Previous { get; set; }
public virtual string Current { get; set; }
}
// subclass
public class SQTextBox : SQControl
{
public SQTextBox()
{
this.Type = typeof(SQTextBox).Name;
}
}
//subclass
public class SQDropDown : SQControl
{
public SQDropDown()
{
this.Type = typeof(SQDropDown).Name;
}
[UIHint("DropDown")]
public override string Current { get; set; }
}
// collection container used as the Model for a view
public class SQControlsCollection
{
public List<SQControl> Collection { get; set; }
public SQControlsCollection()
{
Collection = new List<SQControl>();
}
}
所以我的问题是,有没有更好的方法在回发之间维护基类型集合中的项类型?我知道在MVC中,每个模型都有一个类型化视图是一种惯例,但我希望能够使用可重用的局部视图基于XML文档动态构建视图。签出
// base class
public class SQControl
{
[Key]
public int ID { get; set; }
public string Type { get; set; }
public string Question { get; set; }
public string Previous { get; set; }
public virtual string Current { get; set; }
}
// subclass
public class SQTextBox : SQControl
{
public SQTextBox()
{
this.Type = typeof(SQTextBox).Name;
}
}
//subclass
public class SQDropDown : SQControl
{
public SQDropDown()
{
this.Type = typeof(SQDropDown).Name;
}
[UIHint("DropDown")]
public override string Current { get; set; }
}
// collection container used as the Model for a view
public class SQControlsCollection
{
public List<SQControl> Collection { get; set; }
public SQControlsCollection()
{
Collection = new List<SQControl>();
}
}