【发布时间】:2017-01-05 15:30:03
【问题描述】:
我想使用 url.content() 在 MVC 中使用 img 标签显示图像。我成功了,但是当有一些空图像时它会显示一个“参数异常”错误,所以我也想显示空图像。这是我的代码。
<img src="@Url.Content(item.image)" alt="Image" height="50" width="50" class="img-circle img-responsive" />
当它有价值但我也想要空图像时它会成功。
【问题讨论】:
-
只需将
img标签包装在if条件中,例如if (!string.IsNullOrWhitespace(item.image))
标签: c# jquery asp.net asp.net-mvc asp.net-mvc-4