Skip to content

Instantly share code, notes, and snippets.

@ech01
Last active August 29, 2015 14:17
Show Gist options
  • Save ech01/9afb339f32dd893b122b to your computer and use it in GitHub Desktop.
Save ech01/9afb339f32dd893b122b to your computer and use it in GitHub Desktop.
Handy way to output a different layout for every other item
@{
int rowCounter = 0;
}
<div>
@foreach(var e in (List)) {
var Content = e.Content;
rowCounter = rowCounter +1;
if (rowCounter % 2 == 0)
{
<div class="media"> <div class="media-left"><img alt="@Content.Title" class="media-object" src="@Content.Picture" /></div>
<div class="media-body"> <h4 class="media-heading">@[email protected]</h4>@Html.Raw(Content.Text)</div> </div>
}
else {
<div class="media"><div class="media-body"> <h4 class="media-heading">@[email protected]</h4>@Html.Raw(Content.Text)</div> <div class="media-right"><img alt="@Content.Title" class="media-object" src="@Content.Picture" /></div>
</div>
}
}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment