Copied to clipboard

Flag this post as spam?

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


  • Peter Cort Larsen 421 posts 1038 karma points
    Jul 06, 2012 @ 22:53
    Peter Cort Larsen
    0

    Recursive DatePicker value In Razor

    Hi,

    To get a recursive value in Razor, where i move up to parent node, to see if this has value for a property, i can use the code below.

    var eventLocation = @Model.AncestorsOrSelf().Where("eventLocation.ToString() != string.Empty").Last().eventLocation;

    But i dosnt work when the property uses a Date Picker.
    How do i check  the propertys value to see if its set or not?
    Comparing it against an empy string, dosnt work.

    Anyone who can help me solve this?

     

     

  • Peter Cort Larsen 421 posts 1038 karma points
    Jul 08, 2012 @ 21:24
    Peter Cort Larsen
    0

    Hi all,

     

    Finally i found the solution, here it is for others.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines;
    @using uComponents.Core.DataTypes.MultiUrlPicker.Dto;
    @{


        MultiUrlPickerState selectedLinks = GlobalHelpers.GetMultiUrlPickerState(Model.GetProperty("topNavigationLinks", true).Value);
      
        if (selectedLinks.Items.Any())
        {

            foreach (var link in selectedLinks.Items)
            {
                var target = link.NewWindow ? "target=\"_blank\"" : "";
               
                <li><a href="@link.Url"@target>@link.Title</a></li>
            }

        }

        //<multi-url-picker><url-picker mode="URL"><new-window>False</new-window><node-id /><url>http://www.domain1.com</url><link-title>Name1</link-title></url-picker><url-picker mode="URL"><new-window>False</new-window><node-id /><url>domain2</url><link-title>name2</link-title></url-picker></multi-url-picker>

    }

Please Sign in or register to post replies

Write your reply to:

Draft