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

    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,

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

    From the documentation:

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

Write your reply to: