Questions tagged [defaultmodelbinder]

For questions about .NET API DefaultModelBinder Class

Useful links

101 questions
44
votes
6 answers

MVC3 Non-Sequential Indices and DefaultModelBinder

Is it true that the default model binder in MVC 3.0 is capable of handling non-sequential indices (for both simple and complex model types)? I've come across posts that suggest it should, however in my tests it appears that it does NOT. Given post…
mindlessgoods
  • 1,075
  • 1
  • 11
  • 20
24
votes
4 answers

ASP.NET MVC posted file model binding when parameter is Model

Is there any way to get posted files () to take part in model binding in ASP.NET MVC without manually looking at the request context in a custom model binder, and without creating a separate action method which only takes a…
bzlm
  • 9,198
  • 5
  • 59
  • 86
16
votes
3 answers

How to send a list of int with jQuery to ASP.net MVC Default Model Binder

When I send a list of int's with jQuery like this: $.ajax('@Url.Action("Execute")', { type: 'POST', data: { pkList: [1,2,3] } }); Then jQuery will transform the pkList object and send it by post like…
Marc
  • 6,535
  • 9
  • 43
  • 75
14
votes
3 answers

Default Model Binder does not bind for Nullable types in IEnumerable

I have a controller action whose definition looks like- public ActionResult ChangeModel( IEnumerable info, long? destinationId) And the model: public class MyModel { public string Name; //Gets populated by default binder public…
13
votes
6 answers

Decimal values with thousand separator in Asp.Net MVC

I have a custom model class which contains a decimal member and a view to accept entry for this class. Everything worked well till I added javascripts to format the number inside input control. The format code format the inputted number with…
user123517
13
votes
1 answer

ASP.NET MVC DefaultModelBinder with nested lists

I have a View with a table representing an employee's timesheet. Days across the top, projects down the side, with each day/project intersection containing two values for regular hours and overtime. The (simplified) class definitions for the page…
Brant Bobby
  • 14,107
  • 14
  • 75
  • 114
12
votes
1 answer

.NET core custom and default binding combined

I'm creating a custom model binder for a view model, implementing IModelBinder I have a lot of properties in my view model, the majority of which do not need any custom binding. Rather than explicitly set all of the property values on my model…
11
votes
2 answers

bind attribute include and exclude property with complex type nested objects

Ok, this is weird. I cannot use BindAttribute's Include and Exclude properties with complex type nested objects on ASP.NET MVC. Here is what I did: Model: public class FooViewModel { public Enquiry Enquiry { get; set; } } public class Enquiry…
tugberk
  • 54,046
  • 58
  • 232
  • 321
8
votes
3 answers

ASP.NET MVC 3 Validation on Nested Objects not working as expected - validates child object twice and not parent object

I am trying to get ASP.NET MVC 3 to generate forms from complex, nested objects. There is one validation behaviour I found which was unexpected and I am not sure if it's a bug in the DefaultModelBinder or not. If I have two objects, lets call the…
nootn
  • 851
  • 1
  • 11
  • 16
8
votes
2 answers

ASP.NET MVC default binder: too long ints, empty validation error message

I've got the following model class (stripped for simplicity): public class Info { public int IntData { get; set; } } Here's my Razor form that uses this model: @model Info @Html.ValidationSummary() @using (Html.BeginForm()) { …
Zruty
  • 7,697
  • 1
  • 22
  • 31
7
votes
1 answer

DefaultModelBinder Problem with nested levels + other binders

I have what I would think is a somewhat normal situation where I need to bind form posts to an "order" model. This model has a few levels of information to it: Order.Billing.FirstName Order.Billing.Address.City Order.Billing.Address.Country Using…
claco
  • 751
  • 1
  • 8
  • 17
6
votes
3 answers

Is there a reason why the default modelbinder doesn't bind to fields?

I'm using ASP.NET MVC3 and i'm wondering that the default modelbinder binds to public properties but not to public fields. Normally i just define the model classes with properties but sometimes i use some predefined classes which contains some…
Jan
  • 15,356
  • 5
  • 33
  • 58
6
votes
5 answers

DefaultModelBinder cannot deserialize .NET Dictionary object passed to an action as a JSON object?

I have a very simple class: public class FilterItem { public Dictionary ItemsDictionary { get; set; } public FilterItem() { ItemsDictionary = new Dictionary(); } } I want to populate the data…
6
votes
3 answers

Model Binder in ASP.NET webforms

For number of years I did ASP.NET web forms development I was spoiled by a proprietary library, which allowed me to do things like: UpdateToObject(ControlsCollection, obj) UpdateFromObject(ControlsCollection, obj) Conceptually code did…
Sherlock
  • 972
  • 7
  • 16
6
votes
5 answers

ASP.NET MVC Beta 1: DefaultModelBinder wrongly persists parameter and validation state between unrelated requests

When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data…
1
2 3 4 5 6 7