Copied to clipboard

Flag this post as spam?

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


  • Chuck 71 posts 69 karma points
    Aug 22, 2012 @ 22:27
    Chuck
    0

    .Children.First()

    We are writing a razor script to pull the first child under a media folder. We are using this code, but it keeps throwing an error. Any advice? 

    @Library.MediaById(3352).Children.First()

  • Ben Norman 167 posts 276 karma points
    Aug 22, 2012 @ 22:36
    Ben Norman
    0

    this should work if the mediaById call has worked

    var child = @Library.MediaById(3352).Children.FirstOrDefault();
    if (child != null)
    {
    //do something if there was something in the list
    }
    else
    {
    //do something if there wasn't anything in the list
    }
  • Chuck 71 posts 69 karma points
    Aug 22, 2012 @ 22:56
    Chuck
    0

    Our original script works. What we determined with aid of the debugger was that the mini profiler was throwing errors, once we uninstalled that package the script ran without issue. We don't know why that fixed it, but we know it did. 

     

Please Sign in or register to post replies

Write your reply to:

Draft