我有一个搜索对象内部的填充物另一个类
public class MainModel
{
public UserML userLM;
public Search search;
public MainModel()
{
userLM = new UserML();
search = new Search();
}
}
的主力机型是我使用什么我的视图填充搜索对象,但我始终在提交时获得空值(在我的控制器中放置断点)
示例字段:
@Html.LabelFor(model => model.search.fname)
@Html.EditorFor(model => model.search.fname, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.search.fname, "", new { @class = "text-danger" })
模型传递给视图:
WebApp1.MainModel
这可能吗?有任何想法吗?
看,这也:
create-an-object-inside-another-class-c
参考[这](https://stackoverflow.com/a/7789986/3462759) – tchelidze