I'd like to set the src value to ImgLink if the number of elements in my iList is >= 7 and set it to an empty string if not.
I tried this
<div><img [email protected] >= 7 ? "@UrlResolver.Current.GetUrl(Model.SlideshowItems[6].ImgLink)" : ""></div>
CodePudding user response:
You can do something like:
@{
string src = "img/exampleDefault.png";
if (//logic)
{
src = "img/example2.png";
}
}
<div><img src=@src></div>
you can reduce the logic to one line:
@{
string src = //logic ? "img/example1.png" : "img/example2.png";
}