Articles : Page 1 of 1

  • DropDownList and SelectListItem Array Item Updates in MVC

    DropDownList and SelectListItem Array Item Updates in MVC

    May 12
    16

    So 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

    Passing multiple POST parameters to Web API Controller Methods

    May 12
    09

    ASP.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

    Custom Model Binder for binding drop downs into a DateTime in MVC

    Jul 11
    06

    I 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?

    What’s the Difference Between a Value Provider and Model Binder?

    Jun 11
    30

    ASP.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...


  • Being Constructive

    Being Constructive

    Mar 11
    19

    I want to like Entity Framework. I did a whole screencast series on the thing and to be honest, I grew to like it. It’s very capable and if you play along with it’s rules can save you a lot of work. This post isn’t about EF. It’s about an MSDN post that was put up that I just linked to - and I thought about it afterward and … well I could probably be a bit more constructive. It’s late, I’ve had a beer or 2, and I was a bit quick to hit publish. The thing that pushed me over a bit was this ...


  • Being Constructive

    Being Constructive

    Mar 11
    19

    I want to like Entity Framework. I did a whole screencast series on the thing and to be honest, I grew to like it. It’s very capable and if you play along with it’s rules can save you a lot of work. This post isn’t about EF. It’s about an MSDN post that was put up that I just linked to - and I thought about it afterward and … well I could probably be a bit more constructive. It’s late, I’ve had a beer or 2, and I was a bit quick to hit publish. The thing that pushed me over a bit was this ...


  • Model Binding Decimal Values

    Model Binding Decimal Values

    Mar 11
    19

    I’m in the beautiful country of Brazil right now (I’ll hopefully blog more about that later) proctoring for the hands-on labs that’s part of the Web Camps agenda. However, the folks here are keeping me on my toes asking me to give impromptu and deeply advanced demos. It almost feels like a form of performance art as I create brand new demos on the fly. During this time, several people reported issues binding to a decimal value that prompted me to write a new demo and this blog post. Let...



  • 1