【发布时间】:2011-02-24 07:45:39
【问题描述】:
我有以下代码,我很惊讶它给了我错误消息:
没有为此对象定义无参数构造函数。
public ActionResult CreateEmployee(int ID, string Name)
{
Employee model = new Employee(ID, Name);
return View(model);
}
[HttpPost]
public ActionResult CreateEmployee(Employee model)
{
try
{
return RedirectToAction("Tasks");
}
catch (Exception e)
{
ModelState.AddModelError("Error", e.Message);
return View(model);
}
}
public ActionResult Tasks(int ID, string Name)
{
EmployeeListModel model = new EmployeeListModel(ID, projectName);
return View(model);
}
查看 CreateEmployee:
@model MvcUI.Models.Employee
@using (Html.BeginForm())
{
@Html.Partial("EmpDetails", Model)
<p> <input type="submit" value="Save" /></p>
}
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-mvc-3