This is my model:
public class IndexViewModel
{
public FilterConditions conditions { get; set }
public IEnumerable<SelectListItem> Countries { get; set }
}
public class FilterConditions
{
public string condition11 { get; set }
}
And I have an action method Index, for example:
public ActionResult Index()
{
var model = new IndexViewModel();
return View(model);
}
The view displays a form with filter conditions as input types.
Now I want the message back from this form to be processed using this action method:
[HttpPost]
public ActionResult Index(FilterConditions model)
{
}
and it really works (I set a breakpoint in the method and is called), but the properties of my model are always empty (default values), while they should contain the values that were submitted by the form.
When I change the action method as follows:
[HttpPost]
public ActionResult Index(IndexViewModel model)
{
}
Everything works as it should, but it’s not “right” (IMHO), since I don’t need the “Countries” list when I return, I only need the selected country (which is one of the conditions).
( ), ?
Btw, ASP.NET MVC 2 ( , , , MVC 3, ).
( " " dropdownlists viewmodels asp.net mvc, , , , "" . , ( ), , . " " , .)
:
, [Bind] " ". . ( , ) .
, ( ajax), , . ?