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 1287 posts 2744 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 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 20, 2014 @ 20:46
    Jeavon Leopold
    101

    Hi Amir,

    How about !string.IsNullOrWhiteSpace(combinedPropsHuman)

    Jeavon

  • Amir Khan 1287 posts 2744 karma points
    Mar 20, 2014 @ 20:50
    Amir Khan
    0

    That'll do it, thanks Jeavon!

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 20, 2014 @ 20:52
    Jeavon Leopold
    0

    Awesome!

Please Sign in or register to post replies

Write your reply to:

Draft