Copied to clipboard

Flag this post as spam?

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


  • Ast35 23 posts 44 karma points
    May 01, 2012 @ 15:37
    Ast35
    0

    Checking whether anything has been selected in a Content Picker using razor

    If I try to make use of a field in a page selected by a content picker as below and there is no page selected, I get an error. Can anybody please tell me how to check whether anything is selected with the content picker before referring to the variable?

    Thanks.

    @Model.NodeById(Model.panel1Selector).column1

  • gilad 185 posts 425 karma points
    May 01, 2012 @ 15:41
    gilad
    0

    Try this : 

    @if ( ( Model.panel1Selector != null) && (Model.panel1Selector.ToString() != ""))
    {
    <span>@Model.NodeById(Model.panel1Selector).column1</span> 
    }
  • Ast35 23 posts 44 karma points
    May 01, 2012 @ 16:36
    Ast35
    0

    Ah, that's great, thanks!

Please Sign in or register to post replies

Write your reply to:

Draft