I have a document A, which has a child B that contains a Related Links property called "Events".
I'm trying to display the Events-links in A, using a partial view macro.
Here's what I have ..
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Newtonsoft.Json.Linq
@{
var s = CurrentPage.Children.First();
if (s.HasValue("Events") && s.Events.ToString().Length > 2)
{
<ul>
@foreach (var item in s.Events)
{
<li>
@(item)
</li>
}
</ul>
}
}
This produces the following output
[
{
"
c
a
p
t
i
o
n
"
:
"
T
o
u
r
D
o
w
n
U
n
d
e
r
So it is giving me all the characters separately, instead of returning links!
(I have tried a different approach, with GetPropertyValue<JArray>("Events"), but that gives me an error, the call returns a null reference. It doesn't give an error for GetPropertyValue<string>("Events"), but that returns only the characters, as above, so not useful).
Retrieve Related Links from child
Hello ...
I have a document A, which has a child B that contains a Related Links property called "Events".
I'm trying to display the Events-links in A, using a partial view macro.
Here's what I have ..
This produces the following output
So it is giving me all the characters separately, instead of returning links!
(I have tried a different approach, with
GetPropertyValue<JArray>("Events")
, but that gives me an error, the call returns a null reference. It doesn't give an error forGetPropertyValue<string>("Events")
, but that returns only the characters, as above, so not useful).Any ideas?
Thanks
Guy
I should have posted earlier, because I found a way around it straight afterwards.
If I change this line
for this one
... it works!
Any idea why the JSON had to be explicity parsed? It came out like this (pre-parsing):
is working on a reply...