Reputation: 115
In my MVC application, user can upload various type of files (pdf, jpg, txt etc) and I want to show icon specific to each type, currently I am using one icon (pdf) for the purpose, I want, that based on the file type, associated icon should be displayed. Please guide me what kind of approach I can use for this purpose
<td>
@if (item.CalibratedBy != null){
<a href = @Url.Action("ViewCertificate", new { fileName = item.CalibrationCert }) >
<img src = "@Url.Content("~/Content/Icons/pdf.jpg")" alt = "attachment" /> </a>
}
</td>
Upvotes: 0
Views: 1192
Reputation: 41530
item
(presumably being passed in through the Model)HtmlHelper
extension method that will take in item.FileType
and return the path to the appropriate icon file to be used. Call this in your <img>
tag.Upvotes: 2