我们可以在MVC列表框中显示图像吗?
模型声明
public List<SelectListItem> Type { get; set; } //Will hold listbox items
public string[]SelectedType { get; set; } //Will hold selected items
列表框的数据
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem() { Text = "A. Best seller ", Value = "1", Selected = false });
items.Add(new SelectListItem() { Text = "B. Special offer callout", Value = "2", Selected = true });
items.Add(new SelectListItem() { Text = "C. Promotion", Value = "3", Selected = false });
items.Add(new SelectListItem() { Text = "4. Banner Large", Value = "4", Selected = false });
model.Type = items;
查看绑定
@Html.ListBoxFor(x => x.SelectedType, Model.Type, new { id = "listType", Multiple = "multiple", Size = 15, style = "width: 100%;" })
它成功显示如下列表框:
我可以用它绑定或显示一些图像吗?图像可以存储在文件系统上还是?并将图像命名为ID,例如1.png,2.png等。
这里有什么方法可以显示图片吗?