MVC列表框 - 在列表框中显示图像

时间:2014-08-14 10:34:12

标签: asp.net-mvc-4 listbox

我们可以在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%;" })

它成功显示如下列表框: enter image description here

我可以用它绑定或显示一些图像吗?图像可以存储在文件系统上还是?并将图像命名为ID,例如1.png,2.png等。

这里有什么方法可以显示图片吗?

0 个答案:

没有答案
相关问题