* モデルバインディング - カスタムモデルバインダー [#a01a0ea5]

** ある型のプロパティに対してカスタマイズされたモデルバインダーを適用する [#v8d4497b]
型毎のカスタムモデルバインダーを作る場合、DefaultModelBinderを継承するバインダークラスもしくはIModelBinderを実装するバインダークラスを作って、Application_Start()でModelBindersに登録する。
 ModelBinders.Binders.Add(typeof(Product), new ProductModelBinder());
*** 参考 [#wbed3c08]
http://www.codeproject.com/Articles/551576/ASP-NET-MVC-Model-Binding-and-Data-Annotation

** アノテーションで指定して、あるプロパティに対してカスタマイズされたモデルバインダーを適用する [#bfaff1de]

*** 参考 [#ffeb905a]
- http://aboutcode.net/2011/03/12/mvc-property-binder.html
- http://stackoverflow.com/questions/2186969/custom-model-binder-for-a-property
- http://aboutcode.net/2011/03/12/mvc-property-binder.html
- http://www.prideparrot.com/blog/archive/2012/6/customizing_property_binding_through_attributes
- http://miso-soup3.hateblo.jp/entry/20130321/1363882379

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS