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 1282 posts 2739 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 3072 posts 13628 karma points MVP 10x admin c-trib
    Mar 20, 2014 @ 20:46
    Jeavon Leopold
    101

    Hi Amir,

    How about !string.IsNullOrWhiteSpace(combinedPropsHuman)

    Jeavon

  • Amir Khan 1282 posts 2739 karma points
    Mar 20, 2014 @ 20:50
    Amir Khan
    0

    That'll do it, thanks Jeavon!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x 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