Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm new to Umbraco world. Currently I'm using nested content in my project, this is an amazing plugin. Now I have a question about how to use url picker in nested content?
Here is my code (but always show me the error:'object' does not contain a definition for 'url' and no extension method 'url' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)):
'object' does not contain a definition for 'url' and no extension method 'url' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("nestedItem");
foreach (var item in items)
var image = item.GetPropertyValue("itemImage");
var UrlPicker = item.GetPropertyValue("itemUrl");
if (image != null)
<div class="col-xs-6 col-md-3">
<img src="@Umbraco.Media(image).UmbracoFile" alt="">
<a href="@UrlPicker.url" target="#" style="text-align: center; margin: 20px;"><h2 style="text-align:center">CONTACT US TODAY</h2></a>
when I run this code, the images, texts was able to works correctly, but the url is working wrong. Did I made some mistake in the code? Can anyone help me to check or give me some idea how does the url picker work in nested content?
Thanks very much!
UrlPicker returns a collection of links, even if only one is selected. I'm guessing something like this will work:
@UrlPicker.First(u => u.IsValid()).Url
Michaël is right. My answer is only valid if you're using this:
Thanks very much David.
Hi Yuxuan Li,
if your url picker is a content picker then the value of UrlPicker will be the Id of the selected node.
You can get the url of the node by using:
or by getting the node:
Thanks Michael, it works great!
Glad that I could help you out!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted