Custom model binder for model inner property

Posted by Andrej Kaurin on Stack Overflow See other posts from Stack Overflow or by Andrej Kaurin
Published on 2009-12-22T14:54:37Z Indexed on 2010/04/12 21:03 UTC
Read the original article Hit count: 579

Filed under:

My model is like this

public class MyModel
{
   string ID {get;set;}
   string Title {get;set;}
   MyOtherModel Meta {get;set;}
}

How to define custom model binder for type (MyOtherModel) so when default binder binds MyModel it calls custom model binder for 'Meta' property. I registered it in App start like:

 ModelBinders.Binders[typeof(MyOtherModel)] = new MyCustomBinder();

but this doesn't work. Any idea or any good article with more infor regarding to model binders?

© Stack Overflow or respective owner

Related posts about asp.net-mvc