Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to use a foreach loop for a slider but having issues with adding 1 to the counter on each pass.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var promoItems = CurrentPage.HeroRepositories.First().HeroItems.Where("Visible"); int bannerCount=1; } <div class="visible-lg"> <ul class='kwicks kwicks-horizontal'> @foreach (var item in promoItems){ <li id="panel-@bannerCount"><img style="max-width:inherit;" src="@item.GetCropUrl("bannerImage", "heroimage-w800-h400")" alt=""><div class="slide-description"><h1>@item.Title</h1><h4>@item.subheading</h4></div></li> @bannerCount++ } </ul></div>
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var promoItems = CurrentPage.HeroRepositories.First().HeroItems.Where("Visible");
int bannerCount=1;
}
<div class="visible-lg">
<ul class='kwicks kwicks-horizontal'>
@foreach (var item in promoItems){
<li id="panel-@bannerCount"><img style="max-width:inherit;" src="@item.GetCropUrl("bannerImage", "heroimage-w800-h400")" alt=""><div class="slide-description"><h1>@item.Title</h1><h4>@item.subheading</h4></div></li>
</ul>
</div>
Hi John,
Try changing @bannerCount++ to just bannerCount++. Does that work?
@bannerCount++
bannerCount++
Thanks for the suggestion but realised just after I posted the question the answer was @@bannerCount++ as I needed to explicitly escape out
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
foreach in razor with counter
I'm trying to use a foreach loop for a slider but having issues with adding 1 to the counter on each pass.
Hi John,
Try changing
@bannerCount++
to justbannerCount++
. Does that work?Thanks for the suggestion but realised just after I posted the question the answer was @@bannerCount++ as I needed to explicitly escape out
is working on a reply...