我現在有定義爲對象Tag
如下:返回列表<T>從視圖到控制器在MVC 3
public class Tag
{
public string Name { get; set; }
}
現在,這是我定義爲模型的集合屬性:
public class MyModel
{
public string Name { get; set; }
public IList<Tag> Tags { get; set; }
}
在我看來,我有以下代碼:
@using (Html.BeginForm())
{
<div>
@Html.LabelFor(m => m.Name)
@Html.TextBoxFor(m => m.Name)
</div>
<div>
<!--
Here I'd like a collection of checkbox inputs, where the selected names
get passed back to my controller via the IList<Tag> collection
-->
</div>
<input type="submit" value="Submit" />
}
如何通過我的模型的IList集合返回複選框組中的選定項目(在註釋中指定)?
這是極好的!到底是什麼,非常感謝! –