【发布时间】:2014-02-02 13:36:38
【问题描述】:
我需要显示一个能够选择多个项目的下拉列表。我可以将它与 Dictionary 对象绑定,并且它适用于纯文本值。但是,我还需要在值中包含 img 标签。
这基本上是一个人员列表以及他们的公开头像。但是,列表显示的是 html 标记,而不是显示实际的图像。
这是我认为的剃须刀代码:
@Html.ListBox("MyFriends", new MultiSelectList(Model.Connections.Distinct(), "key", "value"), new { @class = "list-item"})
输出显示为:
<img src="http://localhost/api/person/1211/dp" title="avatar" /> John Smith
<img src="http://localhost/api/person/1212/dp" title="avatar" /> Person Two
<img src="http://localhost/api/person/1213/dp" title="avatar" /> Person 3
<img src="http://localhost/api/person/1214/dp" title="avatar" /> Rick Rude
但我想实际显示显示图片,后跟名称。有什么解决办法吗?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 razor