我有一个基类:
public class Baseclass
{
public string Name { get; set; }
public string LastName { get; set; }
}
从Baseclass继承的类:
public class Inheriteclass : Baseclass
{
public string MyProperty { get; set; }
}
因此,您需要在第一个视图中填写“名称”和“姓氏”,然后单击“下一步”,然后转到具有更多字段的另一个视图。
但是当我在该视图中单击“提交”按钮时,属性“名称”和“姓氏”为空...
首页“下一步”按钮:
public IactionResult GoToCategoryView(Baseclass baseclass)
{
return RedirectToaction("NextView",baseclass);
}
下一个视图有:
@model Inheritanceclass
当我单击“提交”按钮时:
public IactionResult SubmitThis(Inheritanceclass inheritanceclass )
{
var testClass = new testClass
{
Name = inheritanceclass.Name,LastName = inheritanceclass.LastName,MyProperty = inheritanceclass.MyProperty
};
return View(testClass);
}
更新 样品更清晰。在上面的示例中,“名称”和“姓氏”为空。