tags:

views:

79

answers:

1

Hi,

I have a domain object Thing which can contain several Categories. So I have implemented my HTML helper to create a checkbox group of all possible Categories. I have no problem receiving:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Thing Thing, List<string> Categories)

However I am wondering whether I could use a custom Model binder to use just this:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Thing Thing)

So basically I am looking for a way to use the model binder to bootstrap the object tree/graph.

Any pointers appreciated. Thanks.

Christian

A: 

I was mixing up domain objects and DTOs. Making Thing a DTO (or view object?) does the trick.

so having something like this works:

class Thing ( List Categories; )

The model binder figures out how to put the posted data into the Categories

csetzkorn