Asp.net mvc 4 MVC列表框-在列表框中显示图像

Asp.net mvc 4 MVC列表框-在列表框中显示图像,asp.net-mvc-4,listbox,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 它成功显示列表框,如下所示: 我可以用它绑定或显示一些图像吗?图像可以存储在文件系统中,或者?并将图像命名为ID,例如1.png、2

我们可以在MVC列表框中显示图像吗

模型声明

public List<SelectListItem> Type { get; set; }      //Will hold listbox items
public string[]SelectedType { get; set; }       //Will hold selected items
它成功显示列表框,如下所示:

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


有没有办法在这里显示图像?

我认为这是不可能的。您可以为listbox或第三方控件(Google for it)创建一些html帮助程序。但这在传统的列表框中是不可能的。是的,它似乎需要使用一些第三方。我看到了一些免费但没有开源的东西为什么你想把它放在listbox里?它在某种形式内吗?是的。它是一个大表单的一部分,您可以使用带有图像的复选框数组,这也为您提供了多次选择的便利,还可以将所选项目的数组发送到控制器操作。
    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 });
@Html.ListBoxFor(x => x.SelectedType, Model.Type, new { id = "listType", Multiple = "multiple", Size = 15, style = "width: 100%;" })