I'm trying to loop through media items in a media folder. I have succeeded by using the macro template for doing just that. But when I add a <ul> to present the items in a list I get this error: "No overload for method 'Write' takes 0 arguments'."
Why? What went wrong? Any help is appreciated.
This is my razor code:
@{ @* Get the macro parameter and check it has a value otherwise set to empty hive Id *@ var mediaFolderID = String.IsNullOrEmpty(Model.MacroParameters.mediaFolderID) ? HiveId.Empty.ToString() : Model.MacroParameters.mediaFolderID; } @if (mediaFolderID != HiveId.Empty.ToString() && HiveId.TryParse(mediaFolderID).Success) { var mediaFolder = Umbraco.GetDynamicContentById(mediaFolderID);
Kasper, I agree with gilad on what this looks like. Try this:
@{ @* Get the macro parameter and check it has a value otherwise set to empty hive Id *@ var mediaFolderID = String.IsNullOrEmpty(Model.MacroParameters.mediaFolderID) ? HiveId.Empty.ToString() : Model.MacroParameters.mediaFolderID; if (mediaFolderID != HiveId.Empty.ToString() && HiveId.TryParse(mediaFolderID).Success) { var mediaFolder = Umbraco.GetDynamicContentById(mediaFolderID); if (mediaFolder.Children.Any()) { <ul> @foreach (var mediaItem in mediaFolder.Children) { var fileURL = Umbraco.GetMediaUrl(mediaItem.Id, "uploadedFile"); <li> <p> <strong> <a href="@fileURL" title="@mediaItem.Name">@mediaItem.Name</a> </strong> <br /> <span class="subPageDate">Sidst opdateret @mediaItem.UpdateDate.ToString("dd/MM/yyyy hh:mm")</span> <br />@mediaItem.fileDescription </p> </li> } </ul> } } }
Find an error: Looping media items
I'm trying to loop through media items in a media folder. I have succeeded by using the macro template for doing just that. But when I add a <ul> to present the items in a list I get this error: "No overload for method 'Write' takes 0 arguments'."
Why? What went wrong? Any help is appreciated.
This is my razor code:
Hii kasper
try remove the @ from this line :
like this:
Kasper, I agree with gilad on what this looks like. Try this:
Hi guys
Yes, that works perfect! (exept that you Grant had one } to much :-) )
Thanks for your quick help
is working on a reply...