Copied to clipboard

Flag this post as spam?

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


  • BEWD 90 posts 303 karma points
    May 29, 2016 @ 13:35
    BEWD
    0

    If statement in a @for each to change style if a box is ticked

    Hi,

    I have the code below working perfectly, however, I would like to change the design of on of the items if its 'featured' checkbox is ticked. I have the design sorted so that isnt the question, my question is how do I incorporate the the If checkbox is ticked that style like xxxx

    @foreach(var item in selection){
    
    <div class="col-sm-6 col-md-3">
        <div class="wow zoomIn" data-wow-duration="400ms" data-wow-delay="0ms">
            <ul class="pricing">
                <li class="plan-header">
                    <div class="price-duration">
                        <span class="price">@item.Price
                        </span>
                        <span class="duration">@item.Term
                        </span>
                    </div>
                    <div class="plan-name">
                        @item.Name
                    </div>
                </li>
                <li><strong>@item.Rooms</strong> Rooms</li>
                <li><strong>@item.Hectares</strong> Hectares</li>
                <li><strong>@item.Walks</strong> Walks</li>
                <li><strong>@item.Miles</strong> Miles</li>
                @if (item.HasValue("Available"))
                {
                    <li>Available Now</li>
                }
                <li><strong>@item.EmailAddres</strong> EMAIL ADDRESS</li>
                <li><strong>12 Weeks</strong> Notice</li>
                <div class="element-bottom-30"></div>
                <div class="pricing-button">
                    <a href="#">
                        <div class="btn btn-stroke btn-rounded btn-medium">Show Interest</div>
                    </a>
                </div>
    
            </ul>
    
        </div>
    </div>
    }
    

    To style differently all I need to do is change the ul to

      Does this make sense?

      Thanks in advance

      Ben

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 29, 2016 @ 19:09
    Paul Seal
    100

    I would change the ul to be like this:

    <ul class="pricing @(item.HasValue("featured") && (bool)item.featured ? "featured-class-name" : "")">
    
  • BEWD 90 posts 303 karma points
    Jun 01, 2016 @ 11:34
    BEWD
    1

    Cheers Paul, I got that working gperfectly

Please Sign in or register to post replies

Write your reply to:

Draft