Copied to clipboard

Flag this post as spam?

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


  • mmmoustache 50 posts 79 karma points
    May 11, 2012 @ 15:56
    mmmoustache
    0

    Is it possible to use .Contains on an IF statement?

    Hi Everyone,

    The title is pretty transparent, but I was just wondering if it's possible to run an if statement to check if a node property contains a certain value or phrase. I know of .Contains() as part of a foreach loop but is there an equivalent for an if statement? Something like this:

    @if(@node.aProperty.Contains("Hello World")){
    // Do Something
    }


    Kind Regards,
    mmmoustache

  • Jon Free 14 posts 34 karma points
    May 15, 2012 @ 17:06
    Jon Free
    0

    From the documentation:

    @foreach(var item in Model.Children.Where("bodyText.Contains(\"cat\")"))
    {
        @item.Name
    }
Please Sign in or register to post replies

Write your reply to:

Draft