Hi. I did a test run upgrade to version 7. So I'm not sure if my terminology is correct, but now the razor macros throw exceptions. They fail when accessing custom properties, like - page.CustomProperty.
So here is some sample code that will no longer work.
@inherits Umbraco.Web.Macros.PartialViewMacroPage @using System.Linq; @{ var subpages = CurrentPage.Descendants("umbPage").OrderBy("Name"); foreach (var page in subpages) { string x = page.CustomProperty; // this line craps out } }
On version 6, this worked. Is there a different way to do this on 7? Thanks.
Thanks Jeavon. I put the "string x" just as an example. The exception happens on page.CustomProperty, and the debugger says that the property does not exist.
I also tried page.Properties["CustomProperty"], but that didn't work either. Did something change with dynamics in Umb7?
How about doing some checks to see if that changes things?
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var subpages = CurrentPage.Descendants("umbPage").OrderBy("Name");
foreach (var page in subpages)
{
if (page.HasProperty("CustomProperty") && page.HasValue("CustomProperty"))
{
string x = page.CustomProperty; // this line craps out
}
}
}
Unfortunately I had to scrap plans to go to version 7 for the time being, because of this and other problems. Will definitely try that when I get a chance though.
umbraco 7 and razor dynamic woes
Hi. I did a test run upgrade to version 7. So I'm not sure if my terminology is correct, but now the razor macros throw exceptions. They fail when accessing custom properties, like - page.CustomProperty.
So here is some sample code that will no longer work.
On version 6, this worked. Is there a different way to do this on 7? Thanks.
This looks generally ok, perhaps try changing your variable to being implicit instead of explicit, e.g.
Also do you know what the error is?
Thanks Jeavon. I put the "string x" just as an example. The exception happens on page.CustomProperty, and the debugger says that the property does not exist.
I also tried page.Properties["CustomProperty"], but that didn't work either. Did something change with dynamics in Umb7?
How about doing some checks to see if that changes things?
Hmmm, ok. Your first suggestion worked.
Then I could call x.ToString() or do whatever I needed.
So it seems like something has indeed changed with the datatypes when I upgraded to 7. The custom properties used to come through as strings.
Thanks again.
Lets see what it is then
Unfortunately I had to scrap plans to go to version 7 for the time being, because of this and other problems. Will definitely try that when I get a chance though.
is working on a reply...