Hi
Im using a contentpicker to choose a page
I get the id but when i im converting to IPublished content
Object reference not set to an instance of an object.
Many thanks Christina
At a first glance I think your example looks right but I'm wondering if you perhaps need to cast the nodeId to be an int. Could you please try writing it like my example below?
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Activities>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@using Umbraco.Web;
@{
@* Cast the nodeId to an int here *@
var nodeId = Model.GetPropertyValue<int>("nodeId");
}
@if (nodeId != null)
{
var page = Umbraco.TypedContent(nodeId);
foreach (var child in page.Children)
{
<a href="@child.Url">@child.Name</a>
}
}
}
var page = Umbraco.TypedContent(nodeId); returning Object reference not set to an instance of an object.
Hi Im using a contentpicker to choose a page I get the id but when i im converting to IPublished content
Object reference not set to an instance of an object. Many thanks Christina
Hi Christina
At a first glance I think your example looks right but I'm wondering if you perhaps need to cast the nodeId to be an int. Could you please try writing it like my example below?
Does this help?
/Jan
Hi Jan Many thanks, yes it worked. /Christina
Happy to hear Christina - Happy umbracoing! :-)
/Jan
is working on a reply...