Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1199 posts 2567 karma points
    Mar 20, 2014 @ 20:31
    Amir Khan
    0

    Razor if statment with empty string

    Hi, I'm trying to check for an empty string, but a string with just spaces is coming back as "not empty", is there a way to check for any spaces and also return empty? Here's what isn't working:

    @combinedPropsHuman != String.Empty
  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Mar 20, 2014 @ 20:46
    Jeavon Leopold
    101

    Hi Amir,

    How about !string.IsNullOrWhiteSpace(combinedPropsHuman)

    Jeavon

  • Amir Khan 1199 posts 2567 karma points
    Mar 20, 2014 @ 20:50
    Amir Khan
    0

    That'll do it, thanks Jeavon!

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Mar 20, 2014 @ 20:52
    Jeavon Leopold
    0

    Awesome!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies