How to find a Property Value from within the controller with Umbraco Helper?
So, I have been trying to make an AJAX call and I want to return the data of a bunch of children nodes that don't have a template to the call so it can display them as I told it to.
I tried getting the nodes in a few ways but nothing seems to be working. I basically wanted to store the property value in a variable and then pass it to the call. Last one I've tried was this. I'm using Surface Controllers.
var findInUmbraco = Umbraco.Content(1063).DescendantsOrSelf("lekseisDiatrofikouLeksikou").GetPropertyValue(query);
What am I missing? I know that as a thought it's correct, but my execution sucks.
I'm sorry, no I didn't solve it, but I don't even know if that's the problem anymore. Anyway yes lekseisDiatrofikouLeksikou is an alias of a node which is a child node, you're correct. I'm going to try your code right now and let you know.
Actually it's not. When I changed it to dynamic with Content the lambda expression created an error. Says I can only use it with TypedContent. However, TypedContent doesn't allow to search for Descendants.... Looking on it now.
How to find a Property Value from within the controller with Umbraco Helper?
So, I have been trying to make an AJAX call and I want to return the data of a bunch of children nodes that don't have a template to the call so it can display them as I told it to.
I tried getting the nodes in a few ways but nothing seems to be working. I basically wanted to store the property value in a variable and then pass it to the call. Last one I've tried was this. I'm using Surface Controllers.
What am I missing? I know that as a thought it's correct, but my execution sucks.
Hi Harry,
Is this - lekseisDiatrofikouLeksikou - document type alias of child nodes?
Do you have some exceptions?
I would write this code in strongly typed manner:
Also please remember that DescendantsOrSelf() returns list, so GetPropertyValue of list can be error.
Hope it will help you.
Thanks,
Alex
I'm sorry, no I didn't solve it, but I don't even know if that's the problem anymore. Anyway yes lekseisDiatrofikouLeksikou is an alias of a node which is a child node, you're correct. I'm going to try your code right now and let you know.
Hi Harry,
Did you solve your problem?
Can you share code?
Thanks,
Alex
Looks like the code doesn't work completely but I fixed it.
I couldn't work it with TypedContent but it did work as Content. Thanks for the help. The working code is:
So topic is solved!
Glad to help you Harry. Have a nice day.
Thanks,
Alex
Actually it's not. When I changed it to dynamic with Content the lambda expression created an error. Says I can only use it with TypedContent. However, TypedContent doesn't allow to search for Descendants.... Looking on it now.
Harry, which version of Umbraco are you using?
This code works for me:
Just copy pasting your code: "Cannot convert lambda expression to type 'string' because it is not a delegate type'.
Harry,
Try this one:
Add a using System.Linq to the top.
You guys both rock. Thank you!
We are happy to help!
Have a nice day.
Alex
You too.
is working on a reply...