Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mov3nforward 117 posts 319 karma points
    Oct 27, 2017 @ 20:11
    Mov3nforward
    0

    Issue with for loop

    Can anyone tell me why the code below will not work? I am getting an error. I want to wrap the carousel item with the beginning and ending tags if certain conditions are met.

    foreach(var item in Umbraco.Content(1287).Children())
    {
        count++;
        @count
    
        if(count ==1){
            <div class="item active">
                <div class="row">
        }
    
        <div class="col-md-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a></div>
    
        if(count ==4){
                </div>
            </div>
        }
    
    }
    
  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Oct 27, 2017 @ 20:34
    Alex Skrypnyk
    100

    Hi

    The problem is that Razor doesn't understand unclosed html tags, try this code:

    foreach(var item in Umbraco.Content(1287).Children())
            {
                count++;
                @count
    
                if(count ==1){
                    @:<div class="item active">
                    @:<div class="row">
                }
    
                            <div class="col-md-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a></div>
    
                if(count ==4){
                    @:</div>
                    @:</div>
                }
    
            }
    

    Thanks,

    ALex

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Nov 01, 2017 @ 13:01
    Alex Skrypnyk
    0

    Hi Mov3nforward

    Did you solve the issue? Share with our community, please )

    Thanks,

    Alex

  • Mov3nforward 117 posts 319 karma points
    Nov 01, 2017 @ 15:37
    Mov3nforward
    0

    Alex,

    Yes, thanks.

    -Lee

Please Sign in or register to post replies

Write your reply to:

Draft