Hi all, just wondering if there is something built into asp.net mvc where I can override how a specific member is bound.
For example, imagine I have a form:
<form ...>
<input type="text" name="Things" />
...
</form>
And I have the controller action that handles the postback:
public ActionResult MyPostbackAction(IEnumerable<int> things)
{
...
}
and enter the following the data in the field: "1, 20, 30, 50" (not including quotation marks).
Of course this won't work, how exactly is the action suposed to convert the string into a sequence of ints? so I want to be able to 'hint' to the binder how I expect it to bind this value.. something like:
public ActionResult MyPostbackAction([SequenceBinder(",")]IEnumerable<int> things)
{
...
}
Where the sequence binder is a binding hint that breaks the incoming value by a separator, and delegates the binding back to the binding infrastructure, so that it can handle binding a sequence of strings into an IEnumerable.
I imagine this is something I would need to actually build, perhaps by creating a new default model binder that ties into a hinting system first.
Just wondering if this already exists, either built in or by the community.
Thanks in advance, Stephen.