Umbraco.TypedContent() becomes dynamic (and stops working!) when rendering a page
Hi,
Not sure if this is a bug or just the way I'm implementing it, but I am seeing inconsistent behaviour with Umbraco.TypedContent() when rendering partial pages.
and on the partial I have the following code (which doesn't work):
var nodeId = PageData[0]; var contentNode = Umbraco.TypedContent(nodeId);
According to Visual Studio, the TypedContent() method is a Dynamic call, and subsequent methods like @contentNode.GetPropertyValue("section") give an error!
If I change the code on my partial to the below, the TypedContent() method is correctly recognised as an IPublishedContent type, and subsequent methods work fine:
var nodeId = 0; nodeId = PageData[0]; var contentNode = Umbraco.TypedContent(nodeId);
Does anyone know why this is happening? In both cases I am passing the same value (an int) into the method, just declaring the int variable locally in the version that works?! :s
Umbraco.TypedContent() becomes dynamic (and stops working!) when rendering a page
Hi,
Not sure if this is a bug or just the way I'm implementing it, but I am seeing inconsistent behaviour with Umbraco.TypedContent() when rendering partial pages.
I render a page using the following code:
and on the partial I have the following code (which doesn't work):
According to Visual Studio, the TypedContent() method is a Dynamic call, and subsequent methods like @contentNode.GetPropertyValue("section") give an error!
If I change the code on my partial to the below, the TypedContent() method is correctly recognised as an IPublishedContent type, and subsequent methods work fine:
Does anyone know why this is happening? In both cases I am passing the same value (an int) into the method, just declaring the int variable locally in the version that works?! :s
Cheers,
Maff
Hi Maff,
PageData[0] is dynamic, if you are 100% sure it's a int, cast it. e.g.
Jeavon
Yes that does the trick - thanks Jeavon :)
Cool :)
is working on a reply...