Questions tagged [modelbinder]

61 questions
2
votes
1 answer

Many-To-Many relationship mapping using a mapping table

I Have the following tables Users -> UserId -> Name Roles -> RoleId -> Name UserRoles -> UserId -> RoleId and the following classes public class Role{ public int RoleId{get;set;} public int Name{get;set;} } public class User{ …
Hemanshu Bhojak
  • 16,972
  • 16
  • 49
  • 64
2
votes
1 answer

Passing data from a ModelBinder to a custom InputFormatter

The Context: In a WebAPI under Asp.net Core 2.1, I must create a POST endpoint, [server]/MyController/{Parameter1}/MoreRouteThing/. I have to create a custom IInputFormatter because the body isn't readable by the default formatters. The Problem:…
Tipx
  • 7,367
  • 4
  • 37
  • 59
2
votes
3 answers

ASP.MVC 1.0 complex ViewModel not populating on Action

I'm 3 days into learning MVC for a new project and i've managed to stumble my way over the multitude of issues I've come across - mainly about something as simple as moving data to a view and back into the controller in a type-safe (and manageable)…
Graham
  • 21
  • 2
2
votes
1 answer

Model binder can't handle double.MAX string representation back to double

Right now I have a ViewModel with a property double Maximum. On the view side it's kept in a hidden input to help with unobtrusive validation. When post backing the values, the binding silently fails. I had to put a breakpoint on this…
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
2
votes
2 answers

How will model binder deals with Readonly & disabled

I have the following two items , one which is readonly:- @Html.TextBoxFor(model => model.Technology.Tag, new { @readonly = "readonly" }) While the other is Disabled:- @Html.DropDownListFor(model => model.Customer.NAME,…
user2583498
2
votes
2 answers

c# mvc model binding nested lists

I got a problem with my model binding. Got here following models: public class RoomScan { public RoomScan() { } public RoomScan(Guid id) { Room_ID = id; Assets = new List(); } //public Guid…
TheSamsa
  • 23
  • 1
  • 4
1
vote
1 answer

ASP.NET MVC ModelBinder not working with GET requests and/or jQuery AJAX?

I seem to have a problem with getting MVC to fill in my custom model parameter when called through GET instead of POST. I have a JavaScript snippet that calls into an action like so: $.getJSON('<%= Url.Action("DoSearch") %>' + location.search, …
andreialecu
  • 3,639
  • 3
  • 28
  • 36
1
vote
1 answer

MVC 2 & TypeConverters, Get the destination type in ConvertFrom where the context is null

I have a TypeConverter on the base class in my project. [TypeConverter(typeof(CodeTypeConverter))] abstract class CodeBase I have a number of classes which inherit this base class TitleCode : CodeBase class PreferenceCode : CodeBase When the thing…
Anthony Johnston
  • 9,405
  • 4
  • 46
  • 57
1
vote
4 answers

asp.net 5 / mvc 6 / model binder / angular

I do not know because when I do a post by angular, objects are not populated, such as categories or status. Just the product. However, note that the Request.Form list, the information is there. The binder is not performed correctly. What am I doing…
Eduardo Tolino
  • 255
  • 4
  • 16
1
vote
3 answers

Remove prefix from posted data in asp.net mvc

I have a view which looks like below. Each field has a prefix attached in the name property, but the model in my backend has property without the prefix. @using (Html.BeginForm("Save", "Home", FormMethod.Post)) { @Html.ValidationSummary(true) …
1
vote
0 answers

MVC 3 Model Binder does not populate object properties

MVC Kendo Grid calls an update method, and using fiddler I can see the objects data in the query string. In debug mode I can also see that the model binder was able to identify the number of objects in the query string. But when I look at my…
Fabio S.
  • 460
  • 7
  • 22
1
vote
1 answer

ModelBinder does not update the session key

I created a Website(it is poco object) model binder, that checks the sessions: public class WebsitesModelBinder:IModelBinder { private const string websitesSessionName = "SelectedSite"; #region IModelBinder Members public…
VolkanUzun
  • 188
  • 2
  • 11
1
vote
1 answer

model binder UI culture DateTime

My application has culture set to en-US and UI Culture set to nl-NL. In my model I have a DateTime field. In my view if I fill in the Datetime field with a date in the Dutch format like 29-01-2014 than the mode binder does not pick it up because it…
user1980412
  • 115
  • 2
  • 10
1
vote
2 answers

Handling invalid values with ModelBinder in ASP.NET MVC 1.0

First of all some context: I have a form, where I post back some objects that are automatically materialized into objects by MVCs built-in ModelBinder:
user191152
1
vote
0 answers

custom events backbone.modelbinder

I'm trying to determine if I can use ModelBinder in a project I'm working on, but I need to be able to run a 3rd-party validation routine before updating the model. I've tried setting up a fiddle to test the Configuration Options mentioned towards…
Trav Stone
  • 21
  • 1