I want to check if file is image. and then you will see a link where you can see the image. But the link only has to appear if file is link. I try it like this:
if (!String.IsNullOrEmpty(item.FileName)) {
var file = item.FileName;
string[] formats = new string[] { ".jpg", ".png", ".gif", ".jpeg" };
if (file == null || file.Contains(formats)) {
viewLink = false;
@Html.DisplayFor(modelItem => item.FileName)
<em>(@Resources.Entity.Environment.Removed)</em>
}
else {
@*@Html.DisplayFor(modelItem => modelItem.Id )*@
<a href="@Url.Action("Details", "FormLibrary", new { id = item.FileName})"><i class="fa fa-fw fa-external-link-square text-info"></i></a>
}
}
But I get this error:
if (file == null || file.Contains(formats)) {