Articles : Page 1 of 1
- Filter:
- Ef
- Modelbinder
-
DropDownList and SelectListItem Array Item Updates in MVC
May 1216So I ran into an interesting behavior today as I deployed my first MVC 4 app tonight. I have a list form that has a filter drop down that allows selection of categories. This list is static and rarely changes so rather than loading these items from the database each time I load the items once and then cache the actual SelectListItem[] array in a static property. However, when we put the site online tonight we immediately noticed that the drop down list was coming up with pre-set values that...
-
Passing multiple POST parameters to Web API Controller Methods
May 1209ASP.NET Web API introduces a new API for creating REST APIs and making AJAX callbacks to the server. This new API provides a host of new great functionality that unifies many of the features of many of the various AJAX/REST APIs that Microsoft created before it - ASP.NET AJAX, WCF REST specifically - and combines them into a whole more consistent API. Web API addresses many of the concerns that developers had with these older APIs, namely that it was very difficult to build consistent REST sty...
-
Custom Model Binder for binding drop downs into a DateTime in MVC
Jul 1106I have a Nullable DateTime Property in my Model I want to bind painlessly with three drop down select boxes I have for Day Month and Year respectively. First thing to do is to make a new shiny custom model binder. I have done mine by inheriting from DefaultModelBinder (which you will need to include System.Web.Mvc to access). using System; using System.ComponentModel; using System.Web.Mvc; namespace Infrastructure.OFP.ModelBinders { public class MyUserModelBinder : DefaultModelBinder { protect...
-
What’s the Difference Between a Value Provider and Model Binder?
Jun 1130ASP.NET MVC 3 introduced the ability to bind an incoming JSON request to an action method parameter, which is something I wrote about before. For example, suppose you have the following class defined (keeping it really simple here): public class ComicBook { public string Title { get; set; } public int IssueNumber { get; set; } } And you have an action method that accepts an instance of ComicBook: [HttpPost] public ActionResult Update(ComicBook comicBook) { // Do something with ComicBo...
- 1

