Questions tagged [defaultmodelbinder]

For questions about .NET API DefaultModelBinder Class

Useful links

101 questions
1
vote
2 answers

Input file autobind to byte[] array in ASP.NET MVC

Anyone managed to get default binder to work with input file control and property of type byte array? If I have a property on my ViewModel named Image and a file input control on my view name Image, default binder issue this error: The input is not…
mare
  • 13,033
  • 24
  • 102
  • 191
1
vote
2 answers

Adding multiple Prefixes to DefaultModelBinder MVC2

I've looked at most of the ModelBinding examples but can't seem to glean what I'm looking for. I'd like: <%= Html.TextBox("User.FirstName") %> <%= Html.TextBox("User.LastName") %> to bind to this method on post public ActionResult…
1
vote
0 answers

Set a Parent property on Child Objects when binding

We have a hierarchical model of the shape (yuml-ized): And a controller action that takes an Order-typed parameter: public ActionResult UpdateOrder(Order order) { ... } With the posted form having fields for the line items, too, we get a tree…
chiccodoro
  • 14,407
  • 19
  • 87
  • 130
1
vote
1 answer

How to set DefaultBinder ModelBinders.Binders.DefaultBinder in asp.net mvc 4 using autofac?

I want to set ModelBinders.Binders.DefaultBinder=new SmartBinder() in asp.net mvc 4 using autofac, what is the right way to do that?
1
vote
1 answer

DefaultModelBinder Returning Subclass MVC4

I've been trying to read about this DefaultModelBinder for a couple of days now but I'm still very confused. I am using MVC 4 & EF 5 TablePerHiearchy structure. My problem is that I have a base class of Resource: public class Resource :…
1
vote
1 answer

HtmlAttributes dictionary not binding correctly

I have a model binding issue with an html helper I'm writing. I have declared a property on my Model to handle html attributes, In short; public IDictionary HtmlAttributes { get; set; } I then render the following html as in Scott…
1
vote
1 answer

How to chain binders in asp.net MVC 4?

I just wrote my first model binder in asp.net MVC. I started with a pure HTML form that had all the inputs with names prefixed by "fm_". public class HuggiesModel { public string fm_firstname { get; set; } public DateTime fm_duedate { get;…
Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
1
vote
3 answers

ASP.NET MVC Issue with Using Reflection Created Objects with the Default Model Binder

I am having a weird issue in ASP.NET MVC with objects not being updated with UpdateModel when passed a formCollection. UpdateModel does not appear to be working properly when the object being updated is created through reflection. Scenario: I have…
1
vote
2 answers

.NET MVC: how to get the model binder to assign null to a list property?

I have a model like so: class Model { public IList Items { get; set; } } class Item { public int Id { get; set; } } I am sending a request to an action method that takes a Model as a parameter. The request contains the following…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
0
votes
0 answers

mode binder decimal to integer without commas

I have web api net framework 4.7 and I made a custom modelbinder that converts decimal numbers to integer. When they call my product post I have cases that come to me with 5.00. I want to take the integer part of the number as 5.On the other hand if…
0
votes
1 answer

DefaultModelBinder Implementation does not populate the model - ASP.NET MVC 2

I have a very simple implementation of the DefaultModelBinder, I need it to fire some custom validation. public class MyViewModelBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext,…
ab_732
  • 3,639
  • 6
  • 45
  • 61
0
votes
2 answers

How to bind a model property with DefaultModelBinder - ASP.NET MVC2

I have the following scenario. I have the Edit/Employee view populated with a model from an Entity Framework entity (Employee) I post from Edit/Employee to the Save/Employee controller action. The Save/Employee action expect another type…
ab_732
  • 3,639
  • 6
  • 45
  • 61
0
votes
1 answer

Custom model binding using reflection in ASP.NET Core

I have the following Model public class MyModel { public string Name {get;set;} public int? Age {get;set;} public string City {get;set;} public decimal? Salary {get;set;} public JObject ExtraFields {get;set;} } I am trying to…
0
votes
1 answer

Problem with defaul binder (probably simple)

I am building a ASP.NET MVC 2 application and have a controller that contains the following actions : public ActionResult Edit() { ... } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(EditUser user) { ... } To this I got a stronge…
Banshee
  • 15,376
  • 38
  • 128
  • 219
0
votes
1 answer

default model binder

Basically i have a form with around 100 elements. The values bind to my model when i submit the form. But i want to work on certain values of the form elements before the values are set. Basically i want the 95 values of elements of the form be set…
Sunil Thamban
  • 75
  • 3
  • 14