I have a foreach loop in a view that display a list of files (pictures – ). What I would like is to make some logic inside razor, that would display another tag if the files arent jpg/png. Something like (pseudo code) :
foreach (var file in Model.Files)
{
if (file.FileExtension == "jpg" || file.FileExtension == "png")
{
//markup do something
}
else
{
//markup do something else
}
}
This is ofcourse not possible. (Or is it haha?).
Any ideas how I can implement that logic in to the model or controller layer?
I don’t see any problem?
Assuming that you’ve got a list of filenames (strings):