Copied to clipboard

Flag this post as spam?

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


  • Preetee Gangoosirdar 56 posts 257 karma points
    Apr 17, 2014 @ 14:59
    Preetee Gangoosirdar
    0

    Cannot get MediaById without an id

    Dear all,

    Am a newbie in umbraco and razor. Am having an issue with in displaying images for slideshow . It gives me the following error Cannot get MediaById without an id . Please find my code below and many thanks for your kind responses.

    P.S am using umbraco v 4.7.0 (Assembly version: 1.0.4868.25116)

    @using umbraco.MacroEngines;
    @using umbraco.cms.businesslogic.media

    @inherits umbraco.MacroEngines.DynamicNodeContext 

    @{
      
      List<DynamicNodeupcomingEventsModel.AncestorOrSelf(1).Descendants("SportEvents").Where("!umbracoNaviHide").Where("startEventDate >= DateTime.Now.Date").OrderBy("startEventDate descending").Items;
      
      
      @Html.Raw("slides : [")
       foreachDynamicNode events in upcomingEvents)
          {

           var title =@events.Name;
           var mediaIdFolder   @events.GetProperty("eventPhotoGallery").Value.ToString();
           var mediaFolder @Library.MediaById(2647)
           var imgpath @mediaFolder.Children.First().HasValue("umbracoFile"@mediaFolder.Children.First().umbracoFile "/media/60612/dummy.jpg";     
            
           var img="{image:";
           var eventName =",title:";
           var eventDate =",dateEvent:";
           var closingslide="},";
           var description@events.GetProperty("eventDescription").Value.ToString();
           
           var startEventDate@library.FormatDateTime(@events.GetProperty("startEventDate").Value.ToString(),"dd/MM/yyyy")
           var endEventDate @library.FormatDateTime(@events.GetProperty("endEventDate").Value.ToString(),"dd/MM/yyyy")
          
         
           
            
          
          
           var slides @img +"\'"+@imgpath+"\'"+@eventName+"\'"+@title +"\'"+@eventDate+"\'"+@startEventDate+"\'"+@closingslide;     
            @Html.Raw(@slides)
          }
      
      @Html.Raw("]")
    }
  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 17, 2014 @ 15:59
    Fuji Kusaka
    100
Please Sign in or register to post replies

Write your reply to:

Draft