我尝试过线程的解决方案:
但我的问题仍无法解决。我的代码似乎很好
视图(DodajWpis):
@model mvc.Models.WpisModel
....
@using (Html.BeginForm("AddedNew", "Home", FormMethod.Post))
{
@Html.Label("Title")
@Html.EditorFor(x => x.title)
@Html.Label("Description")
@Html.EditorFor(x => x.descr)
@Html.Label("Priority")
@Html.EditorFor(x => x.priority)
@Html.Label("Deadline")
@Html.EditorFor(x => x.deadline)
<input type="submit" />
}
控制器:
[HttpGet]
public ActionResult AddNew()
{
WpisModel wpis = new WpisModel();
return View("DodajWpis",wpis);
}
[HttpPost]
public ActionResult AddedNew(WpisModel model)
{
return null;
}
和模型
public class WpisModel
{
[Required(ErrorMessage = "required")]
public string descr;
[Required(ErrorMessage = "required")]
public string title;
[Required(ErrorMessage = "required")]
public int priority;
[Required(ErrorMessage = "required")]
[DataType(DataType.Date)]
public DateTime deadline;
}
我从我的视野中收到一个空模型。我也尝试绑定它(通过this article, "Registering Model Binders" section),但我无法添加代码&#34;绑定(允许=&#34;并且我被困在其中。有人可以看看并帮助我吗?
感谢。