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,
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:
UpdateModel(q, new[] { "Title", "Body", "Tags" },
new QuestionValueProvider(this.ControllerContext));
The QuestionValueProvider I wrote is:
public class QuestionValueProvider : DefaultValueProvider
{
public QuestionValueProvider(ControllerContext controllerContext)
: base(controllerContext)
{
}
public override ValueProviderResult GetValue(string name)
{
ValueProviderResult value = base.GetValue(name);
if (name == "Tags")
{
List tags = new List();
string[] splits = value.AttemptedValue.Split(' ');
foreach (string t in splits)
tags.Add(t);
value = new ValueProviderResult(tags, null, value.Culture);
}
return value;
}
}
Hope this helps