how do i do the following, with an ASP.NET MVC UpdateModel? I'm trying to read in a space delimeted textbox data (exactly like the TAGS textbox in a new StackOverflow question, such as this) into the model.
eg.
<input type="Tags" type="text" id="Tags" name="Tags"/>
...
public class Question
{
public string Title { get; set; }
public string Body { get; set; }
public LazyList<string> Tags { get; set; }
}
....
var question = new Question();
this.UpdateModel(question, new [] { "Title", "Body", "Tags" });
the Tags property does get instantiated, but it contains only one item, which is the entire data that was entered into the Tags input field. If i want to have a single item in the List (based upon Splitting the string via space) .. what's the best practice do handle this, please?
cheers!
What you need to do is extend the DefaultValueProvider into your own. In your value provider extend GetValue(name) to split the tags and load into your LazyList. You will also need to change your call to UpdateModel:
The QuestionValueProvider I wrote is:
Hope this helps