Questions tagged [modelbinder]

61 questions
1
vote
1 answer

ASP.NET MVC Wizard issue

Hi i've used this post to create a wizard in asp.net mvc: multi-step registration process issues in asp.net mvc (splitted viewmodels, single model) It works only with dataannotations on the concrete classes behind the interface …
1
vote
0 answers

Why Backbone Model change function inside a Marionette ItemView change event function triggers more then once?

Im working on a small project, and i have a problem with model binding. I'm using the Backbone.ModelBinder plugin for binding a model. I'm checking changes on inputs, and get the name of the model attribute from the input data-name field. After that…
Robert Bokori
  • 259
  • 1
  • 3
  • 8
1
vote
1 answer

asp.net mvc custom modelbinder - how to perfom updates with assosciated entities

I am trying to understand how associated entities are updated when using custom modelbinders. If you have a Product entity with a relationship to a Category entity and you are displaying a list of category choice for a product in a dropdown on a…
Chev
1
vote
1 answer

NullReferenceException in custom IModelBinder

I'm trying to implement my own custom ModelBinder using MVC4 in .NET 4.5, but get the weirdest error. My code looks approx. like this TableViewModelModel : IModelBinder public object BindModel(ControllerContext ctx, BindingContext btx) { …
thomrand
  • 85
  • 6
0
votes
3 answers

ASp.NET MVC: TryUpdateModel doesn't update all properties

I've got the following action: public ActionResult Create() { var entity = new Employee(); TryUpdateModel(entity, new[] { "Person.Name", "Code", "CompanyID" }); if (ModelState.IsValid) { var result =…
Bruno Shine
  • 1,021
  • 1
  • 9
  • 17
0
votes
3 answers

MVC: Is it possible to have one custom ModelBinder AND the default binder on one model?

I would like to use my custom binder to deal with the constructor (necessary) and then have the default modelbinder fill in the rest of the properties as normal. Edit: The custom one would run first of course.
the_law
  • 215
  • 1
  • 5
  • 13
0
votes
2 answers

Model Binding within a Model Binder

Firstly, bear with me here. I have a custom model binder which is successfully mapping form data to a custom object. Within this model binder it also maps form items to different custom object. What I feel I should be able to do is create a separate…
dave
  • 743
  • 2
  • 8
  • 20
0
votes
0 answers

Pass complex data object in GET request to MVC controller action

I have model class as below: public class HomeFilterModel { public string CompanyName { get; set; } public string Country { get; set; } public DateRange Period { get; set; } } public class DateRange { public DateTime? From {…
Jason Li
  • 1,194
  • 2
  • 11
  • 17
0
votes
0 answers

Use ModelBinder for int array

I have an method in my controller (SurfaceController which is a specific Umbraco controller): public class ProductListController : SurfaceController { public ActionResult GetCategoryProducts([ModelBinder(typeof(IntArrayModelBinder))] int[]…
bjarne_f
  • 105
  • 1
  • 2
  • 12
0
votes
0 answers

Custom ModelBinder constructor seems to never get hit, using Autofac per-request registration

I am using a custom modelbinder in a MVC5 project like this: public class TypedModelBinder : IModelBinder, IModelBinderProvider {...} This classes constructor has some dependencies that I need Autofac to inject for me. Then I have registered the…
Para Jaco
  • 211
  • 2
  • 9
0
votes
2 answers

asp.net mvc 3 rc1. ModelBinder populates all properties with null

I have an object like this public class ParentEntityInfo { public long? ParentId { get; set; } public string EntityName { get; set; } public string ParentProperty { get; set; } } and view for this object…
serg
  • 537
  • 6
  • 14
0
votes
1 answer

Found property which wasn't bound from response body (form data) to model MVC, default model binder

I send post request and get in response body form data: 0[family]=Marco&0[name]=Polo&0[age]=66&1[family]=Family&0[name]=Name&0[age]=22 var formData = "0[family]=Marco&0[name]=Polo&0[age]=66&1[family]=Family&0[name]=Name&0[age]=22"; var data =…
Elena
  • 125
  • 1
  • 9
0
votes
1 answer

ASP.NET MVC - Modelbinding with Dropdownlist

Is it possible to have a single view model with a list that is used for a dropdownlist and also get the selected value of the dropdownlist from the view model when I post a form? If so, how can I do this?
Rookian
  • 19,841
  • 28
  • 110
  • 180
0
votes
1 answer

How to return an overall Model's value as 'null' from ASP.NET MVC model binder

I have an action method that takes several optional parameters. This ASP.NET MVC actionmethod looks simple enough but isn't working as I want.... [HttpPost] public ActionResult UpdateOrder(OrderItem OrderItem, Address ShippingAddress) { if…
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
0
votes
2 answers

Invalid model state in Posting data with form in MVC5

I'm completely new in Asp.net MVC I want to fill a form and post it to data base but my model Binder validation is false . and my Errors which I have in my model doesn't show I'm sorry because I don't know what is the problem I couldn't shorten…
neda Derakhshesh
  • 1,103
  • 2
  • 20
  • 43