Questions tagged [modelbinders]
263 questions
0
votes
1 answer
ASP.NET MVC: null reference exception using HtmlHelper.TextBox and custom model binder
I have written a class which implements IModelBinder (see below). This class handles a form which has 3 inputs each representing parts of a date value (day, month, year). I have also written a corresponding HtmlHelper extension method to print out…

WickyNilliams
- 5,218
- 2
- 31
- 43
0
votes
1 answer
MVC 2, Custom ModelBinder, and storing the "attempted value" for the view
I have an object that was previously round-tripping from the server to the client and back nicely (i.e. edit and view forms worked fine). However, I've added to that object a complex type and made a custom ModelBinder to handle it. The complex…

pbristow
- 1,997
- 4
- 26
- 46
0
votes
2 answers
ASP.NET MVC - Binding a Child Entity to the Model
This one seems painfully obvious to me, but for some reason I can't get it working the way I want it to. Perhaps it isn't possible the way I am doing it, but that seems unlikely. This question may be somewhat related: ASP.NET MVC Model Binding…

Nathan Taylor
- 24,423
- 19
- 99
- 156
0
votes
1 answer
breaking datetime into constituent parts ASP.NET MVC form
i have searched the web relentlessly for this and have not found anything - which is surprising because i would think it is such a common scenario!
Basically, on my model i have a DateTime field which i wish the user to populate through a form. I am…

WickyNilliams
- 5,218
- 2
- 31
- 43
0
votes
2 answers
ASP.Net MVC2 CustomModelBinder not working... Changed from MVC1
(My apologies if this seems verbose - trying to provide all relevant code)
I've just upgraded to VS2010, and am now having trouble trying to get a new CustomModelBinder working.
In MVC1 I would have written something like
public class…

Ian
- 71
- 1
- 2
0
votes
2 answers
ModelBinding Issue with a Struct
I have a ViewModel which contains the following struct:
public struct PricesAndDiscounts
{
public decimal FlatOff;
public decimal UnitPrice;
public decimal TotalDiscount;
public decimal TotalOptions;
public decimal…

onefootswill
- 3,707
- 6
- 47
- 101
0
votes
1 answer
NullReferenceException when testing DefaultModelBinder
I'm developing a project using BDD/TDD techniques and I'm trying my best to stay the course. A problem I just ran into is unit testing the DefaultModelBinder. I'm using mspec to write my tests.
I have a class like this that I want to bind…

Byron Sommardahl
- 12,743
- 15
- 74
- 131
0
votes
1 answer
ASP.MVC 4 DefaultModelBinder fails on empty string binding to List
So if you post empty string to a controller like this
and try to bind it to a List very strange stuff occurs
Does anybody faced this issue?
Why it adds default int value to a list?

Grebets Kostyantyn
- 303
- 3
- 6
0
votes
1 answer
Two field with same name in Custom model binder
I write a custom model binder.
In my page I have a numeric text box that has comma separetor mask.
For examle:
1,234
In my model binder, I get value in text box:
var valueResult =…

Tavousi
- 14,848
- 18
- 51
- 70
0
votes
2 answers
How to update custom ModelBinder to work with altered ModelBindingContext.ValueProvider interface in ASP.NET MVC RC2
I have a custom model binder that takes a comma separated list and cleans out any empty values, then passes it along to the default model binder. This worked in ASP.NET MVC Preview 2, but when I upgraded to RC2, the below won't compile because the…

JeremyWeir
- 24,118
- 10
- 92
- 107
0
votes
1 answer
Binding ViewModels With Other ViewModelBinders
I have a viewmodel (lets call it HouseVM) but it contains another viewmodel inside of it (KitchenVM). I've already created a custom model binder for KitchenVM. Now I'm creating the HouseVM modelbinder. How can I access the model binding I've…

RailRhoad
- 2,128
- 2
- 25
- 39
0
votes
0 answers
Remote Validation attribute in base Model
I have abstract model which has property that will be validated. I want to set current controller for controller parameter.So,I added my custom attribute which inherits from Remote attribute. The problem is validate attribute applies once when model…

AndreyDG
- 25
- 4
0
votes
1 answer
MVC Views and Controllers: Re-instantiate entities when form submitted
We are working with entities in our MVC controllers which are passed to strongly typed views.
How do we re-instantiate these entities in the controller with updated data when the form is posted in the view?
The form does not contain all the fields…

Steve Ward
- 1,207
- 3
- 16
- 42
0
votes
1 answer
Overriding updatecollection in defaultmodelbinder
I'm having a problem with the DefaultModelBinder creating new entities when I bind a entity with child collection rather than updating the existing child entities. I found what looks like a good solution in this post but I don't want to have to…

Joe
- 83
- 6
0
votes
1 answer
I need a DataAnnotationsModelBinder for DataAnnotations v 3.5
I need a DataAnnotationsModelBinder that is going to work with System.ComponentModel.DataAnnotations v 3.5 i have found one on codeplex, but is for the v 0.99 of DataAnnotations and it doesn't work with v 3.5, and my xVal doesn't work with…

Omu
- 69,856
- 92
- 277
- 407