我有一個搜索對象內部的填充物另一個類
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