imodelbinder

IModelBinder and ASP.NET MVC Beta

Does anyone have links to tutorials regarding the new IModelBinder in asp.net mvc beta? I can't get my head around it properly, so much has changed. Thanks ...

Custom IModelBinder and Database Access

For a user object in my asp.net mvc project, I have written a custom modelbinder to check whether passwords are valid and whether two matching passwords were entered etc.. The login name needs to be unique though, I was wondering whether I can check for that in the modelbinder, or is this considered bad practise ? The thing is that th...

Extending Sanderson's custom mvc ModelBinder for an object stored in session

In his wonderful MVC book Steven Sanderson gives an example of a custom model binder that sets and retrieves a session variable, hiding the data storage element from the controller. I'm trying to extend this to cater for a pretty common scenario: I'm storing a User object in the session and making this available to every action method a...

Best Practices when Implementing IModelBinder

I'm looking for a set of best practices to use when implementing IModelBinder. I've read three different MVC books and each one does some slightly different stuff in their implementations without any real explanation. The Hanselman, Haack, Guthrie, Conery book doesn't even mention IModelBinder Palermo recommends extending DefaultModel...

MVC 2, IModelBinder & ValueProvider changes

Hi, I'm trying to migrate to ASP.Net MVC 2 and meet some issues. Here is one : I needed to bind directly a Dictionary as result of a view post. In ASP.Net MVC 1 it worked perfectly using a custom IModelBinder : /// <summary> /// Bind Dictionary<int, int> /// /// convention : <elm name="modelName_key" value="value"></elm> /// </summar...

ASP.NET MVC - Custom model binder able to process arrays

I need to implement a functionality to allow users to enter price in any form, i.e. to allow 10 USD, 10$, $10,... as input. I would like to solve this by implementing a custom model binder for Price class. class Price { decimal Value; int ID; } The form contains an array or Prices as keys keys: "Prices[0].Value" "Prices[0].ID" "Pr...

How do I invoke UpdateModel from within a Custom ModelBinder? (MVC)

Hi, I'm creating a few custom binders for complex types in my Model. My model is composed of objects that have their own separate binders. I want the base object to do its dirty work and then populate the complex object it encapsulates by passing off to the standard ModelBinder routing. How do I do this? For illustration purposes I'...

Asp.net MVC2 IModelBinder is trying to drive me nuts (and succeeding)

Let's say I have class FooClass { } class BarClass { public FooClass Foo; } This BarClass is the Model I'm passing to the ViewPage. I'm also passing (via ViewData) an IEnumerable<SelectListItem> with all the Foo in it, and the one that match the bar.Foo is selected (checked at runtime). I'm then calling Html.DropDownList("Fo...