如何使用 ASP.NET MVC UpdateModel 执行以下操作?我正在尝试将空格分隔的文本框数据(就像新 StackOverflow 问题中的 TAGS 文本框,例如这个)读入模型。
例如。
<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" });
Tags 属性确实被实例化,但它只包含一项,即输入到 Tags 输入字段中的全部数据。如果我想在列表中有一个项目(基于通过空格拆分字符串).. 处理这个问题的最佳做法是什么?
干杯!