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 am using CurrentPage.GetPropertyValue("promo") but the for each not loop thorugh
@{ var SiteLinks = CurrentPage.GetPropertyValue("promo"); if (CurrentPage.HasValue("promo")) { var promoListValue = CurrentPage.GetPropertyValue("promo"); foreach (var item in promoListValue) { <span>@item.alias </span> } } }
i am receive an error but when i print the promoListValue its displaying like this
[ { "alias": "1", "content": "1", "img": "/media/1069/509253678.jpg" }, { "alias": "Slide 2", "content": "2", "img": "/media/1074/636609180.jpg" } ]
can someone help me on this :)
Hi Gayathri
What type of "promo" property? CurrentPage.GetPropertyValue("promo") returns object, you can't loop through object.
Thanks,
Alex
In Umbraco 7.5 you can do
foreach (var item in CurrentPage.Promo) { @item.Alias }
CurrentPage.Promo should return a dynamic type, which can be looped through. Just be careful because it'll be easy to run into errors.
Not tried this method in 7.6
This solution throws an error
: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'char' does not contain a definition for 'Alias'
yeah, i know but i am looking for the solutions :)
do u have any suggestion how can i convert
What do you need to convert it into?
my array is not loop thorugh its printing a strings
Weird, it thinks that the promo value is a string and for each iteration it's using the next char.
Anyway, have you tried using Json.Decode() ? This will convert an object which is JSON into a dynamic which can be looped
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Get Propert Value not listing the for each
i am using CurrentPage.GetPropertyValue("promo") but the for each not loop thorugh
i am receive an error but when i print the promoListValue its displaying like this
can someone help me on this :)
Hi Gayathri
What type of "promo" property? CurrentPage.GetPropertyValue("promo") returns object, you can't loop through object.
Thanks,
Alex
In Umbraco 7.5 you can do
CurrentPage.Promo should return a dynamic type, which can be looped through. Just be careful because it'll be easy to run into errors.
Not tried this method in 7.6
foreach (var item in CurrentPage.Promo) { @item.Alias }
This solution throws an error
: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'char' does not contain a definition for 'Alias'
yeah, i know but i am looking for the solutions :)
do u have any suggestion how can i convert
What do you need to convert it into?
my array is not loop thorugh its printing a strings
Weird, it thinks that the promo value is a string and for each iteration it's using the next char.
Anyway, have you tried using Json.Decode() ? This will convert an object which is JSON into a dynamic which can be looped
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.