I'm using MVC 2.0 with a Html.ListBoxFor as below:
<% using (Html.BeginForm()) { %>
<input type="submit" value=">" />
<%= Html.ListBoxFor(x => x.lstTest, new MultiSelectList(new [] {"someone", "crap", "why"})) %>
<% } %>
When I click the input submit button below with nothing selected, it posts back fine, when I select one of the 3 items in the listbox it throws this error:
System.MissingMethodException: No parameterless constructor defined for this object.
Any ideas? here is my controller code:
[HandleError]
public class HomeController : Controller
{
public HomeController()
{
}
public ActionResult Index()
{
ViewData["Message"] = "Test Harness";
return View();
}
[HttpGet]
public ActionResult About()
{
ViewData["mykey"] = "Test Harness";
LogOnModel model = new LogOnModel();
model.lstTest = new MultiSelectList(new [] {"A", "B", "C"});
return View(model);
}
[HttpPost]
public ActionResult About(LogOnModel model)
{
ViewData["mykey"] = "Test Harness";
model.lstTest = new MultiSelectList(new [] { "" });
return View(model);
}
}