Questions tagged [model-binding]

Model Binding is a feature of ASP.NET MVC, and (from .NET 4.5) ASP.NET WebForms, that simplifies controller actions by using the request data to create strongly typed objects.

Model Binding is a feature of ASP.NET MVC, and (from .NET 4.5) ASP.NET WebForms, that simplifies controller actions by using the request data to create strongly typed objects.

2305 questions
69
votes
3 answers

ASP.NET MVC Binding to a dictionary

I'm trying to bind dictionary values within MVC. Within the action I have: model.Params = new Dictionary(); model.Params.Add("Value1", "1"); model.Params.Add("Value2", "2"); model.Params.Add("Value3", "3"); and within the view I…
user644344
  • 845
  • 1
  • 7
  • 7
62
votes
5 answers

How does MVC 4 List Model Binding work?

If I want a set of inputs in a form to bind to a List in MVC 4, I know that the following naming convention for input name attributes will work:
Eric
  • 5,401
  • 7
  • 35
  • 66
58
votes
4 answers

Polymorphic model binding

This question has been asked before in earlier versions of MVC. There is also this blog entry about a way to work around the problem. I'm wondering if MVC3 has introduced anything that might help, or if there are any other options. In a nutshell. …
Erik Funkenbusch
  • 90,480
  • 27
  • 178
  • 274
53
votes
1 answer

How to pass IEnumerable list to controller in MVC including checkbox state?

I have an mvc application in which I am using a model like this: public class BlockedIPViewModel { public string IP { get; set; } public int ID { get; set; } public bool Checked { get; set; } } Now I have a View to bind a list like…
Praveen VR
  • 1,466
  • 2
  • 16
  • 31
51
votes
3 answers

MVC 3 Model Binding a Sub Type (Abstract Class or Interface)

Say I have a Product model, the Product model has a property of ProductSubType (abstract) and we have two concrete implementations Shirt and Pants. Here is the source: public class Product { public int Id { get; set; } [Required] …
B Z
  • 9,203
  • 13
  • 64
  • 89
51
votes
3 answers

How does a multiple select list work with model binding in ASP.NET MVC?

If you have a select list set to multiple in ASP.NET MVC, how does the modelbinding work? What does it return for your selected items, an array?