defaultmodelbinder

will asp.net mvc model binder keep a posted array in the proper order?

Hello, so i've got an array of numbers that i'm posting to an asp.net mvc action that has a list(of integer) parameter and it all works great. my question is this: Is it safe to assume that the list(of integer) will have the numbers in the same order as they were in the array i posted? Thanks for your time! EDIT: The data being ...

DefaultBinder in MVC problem

Hi! I just started working in MVC and I have a problem: public class ServicePhone { public int AgreementId { get; set; } public List<PhoneNumber> Phones { get; set; } public ServicePhone() { Phones = new List<PhoneNumber>(); } public PhoneNumber NewPhone { get; set; } } public class PhoneNumber { p...

ASP.NET MVC Model Binder not working with a dictionary

Hi, Given the following view model and action using the DefaultModelBinder, it seems to ignore the dictionary, but bind all other properties correctly. Am I missing something here? Looking at the MVC source code this seems legit. Thanks public class SomeViewModel { public SomeViewModel() { SomeDictionary = new Dictiona...

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 Index(UserInputModel input) {} where UserInputModel is public class UserInputModel { public stri...

Input file autobind to byte[] aray 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 a valid Base-64 string as it contains a non-base 64 character, more than two padding cha...

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 something very similar to what MVC Model Binder does, i.e. given form's posted values as inp...

Formatting nullable DateTime fields in strong typed View

Hello, I have a Person class with a BornDate property in my model defined as [DisplayName("Born Date")] public DateTime? BornDate { get; set; } I use this field in my view as <td style="white-space:nowrap"> <%= Html.LabelFor(model => model.BornDate)%> <br /> <%= Html.TextBoxFor(model => model.BornDate, new { id = "bornD...

MVC Default Model Binder - Bind a Multiselect Dropdown to an IList<T>

I'm using MVC 2.0 in an ASP.NET application using NHibernate. I have a working View, Controller and data access layer using NHibernate that is able to display and save an entity with a relationship to another mapped entity: Person -- > Location It's using the HTML helper HTML.DropDownListFor() to display a list of all Locations. The u...

ASP.NET model binding to base type

Hi, I have a BaseViewModel that my View Models all inherit from. public class MagazineViewModel : BaseOutputViewMode { public string TitleOfPublication { get; set; } } In my controller I use a factory method to give the corret View Model back based on an input: // e.g. viewModel contains an instance of MagazineViewModel BaseOu...