0
votes

Check the code bellow. Here I am trying to loop though picture collection but in img tag razor intellisense telling syntax is wrong. error is:

Compiler Error Message: CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

foreach (var theme in Model.Themes)
{
  <img src="https://pic.example.com/@{theme.Id.ToString() + "/" + theme.BannerName;} " alt="Alternate Text" style="width:100%;height:auto;" />
}
1
It's probably that ; after BannerName? - canton7

1 Answers

1
votes

You should change to string.Format as

@foreach (var theme in Model.Themes)
 {
        <img src="https://pic.example.com/@(string.Format("{0}/{1}",theme.Id, theme.BannerName))" alt="Alternate Text" style="width:100%;height:auto;" />
 }