Copied to clipboard

Flag this post as spam?

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


  • Luke Alderton 192 posts 509 karma points
    Jul 18, 2012 @ 17:22
    Luke Alderton
    0

    Empty Content Picker

    Hi there,

    I'm having trouble with a Content Picker on a Media Item. My problem is that when I give the content picker a node, it will return the node id however if the content picker has no node selected then it will return 'umbraco.MacroEngines.DynamicXml' I've tried everything I can think of to check weather the content picker has no node selected but nothing works as it's returing the above stated!

    I'd be greatful if someone could help me out with this problem, how can I check if the content picker is empty?

    Thanks in advance!
    Luke

  • Sobin 25 posts 46 karma points
    Oct 24, 2012 @ 13:57
    Sobin
    0

    Hi ,

    you can try this...

    @if(item.HasProperty("propertyname") &&!string.IsNullOrEmpty(item.propertyname.ToString())) {

    //do some codes..

    }

  • Nicolai Winch Kristensen 50 posts 70 karma points
    May 14, 2013 @ 22:24
    Nicolai Winch Kristensen
    0

    Hi Luke and Sobin

    Did you solve above problem. I have same problem. @Sobins suggestion unfortunaly does not work , it will always return true (no matter if content picker is empty or not)

    see my thread here: http://our.umbraco.org/forum/developers/razor/40892-HasValue,-HasProperty-checking-Content-Picker-with-razor-problem?p=0#comment149566

    Best Regards

    Nicolai

     

  • Luke Alderton 192 posts 509 karma points
    May 15, 2013 @ 12:14
    Luke Alderton
    0

    Hi Nicolai, I can tell you that I did solve the problem, but now theres a new problem. I can't remember what project this was for so I have no way of finding the fix for you. Sorry. :/

  • Charles Afford 1163 posts 1709 karma points
    May 15, 2013 @ 22:04
    Charles Afford
    0

    Dont you want to check if the contentpicker is null?

    if(item.HasProperty("propertyname") && item.getproperty("") != null)

    {

    }

    Charlie :)

Please Sign in or register to post replies

Write your reply to:

Draft