OK, I can confirm that it is the same error was before:
I am not sure why it saying 'string' does not contain, as it should be dynamic XML at this point?
Error Loading Razor Script (file: Carousel) 'string' does not contain a definition for 'url' at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at CallSite.Target(Closure , CallSite , Object ) at ASP._Page_macroScripts_Carousel_cshtml.Execute() in g:\Sites\xxx-xx\xxxx-xxxx\macroScripts\Carousel.cshtml:line 22 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
I have found a work around that means I can continue, but I think there may be a bug somewhere here, as I can't see why the above methods shouldn't work.
The following however works for me:
DynamicNode xmlNode = new DynamicNode(int.Parse(@item.Attribute("link").Value.ToString())); dynamic urlXml = new DynamicXml("" + xmlNode.GetProperty("captionUrl").Value.Replace("-", "") + "");
I then have to check to see if there are any decendents, and output the result
@if (urlXml.Descendants().Count > 0) {
@urlXml.Descendants()[0].url
}
Note, I have to wrap the XML into root nodes, as the URL Picker doesn't have a root, and I also needed to replace properties that had "-" in them, as these were not accessible with the razer syntax
Dynamic XML issue
This one is driving me mad, so I am hoping someone can help!!
I have a "Related Links" property on my page, which links to several other pages in the site.
I loop though each one with
Each, "carouselItem" has got various properties, but the one I am having issues with is a "URL Picker", property name "captionUrl" (from Ucomponents).
If I output "carouselItem.captionUrl", I get "umbraco.MacroEngines.DynamicXml"
But, if I try "carouselItem.captionUrl.url", I get an error "'string' does not contain a definition for 'url'"
@item.Attribute("link").Value is pushing out ints, one of which is "1072", so I tried the following code:
The above works fine, and outputs the URL as expected.
So, I tried setting an int value to @item.Attribute("link").Value. The following code shows that it is being set correctly as an int:
The output of the above is:
Number: 1072 Type: System.Int32
So, I tried combining the above:
But, the above code gives me the same error, I get an error "'string' does not contain a definition for 'url'"
I just don't get it, if I change the code to the following:
It works without error, but as soon as I dynamically set the nodeId, if errors!!
Anyone got any suggestions?
Thanks
Hmm that is strange. What version of Umbraco are you using? DynamicXml has been changed a couple of times.
Jeroen
I am using version 4.7.1, which is one down from the very latest I beleive. (which is 4.7.1.1 if I am not mistaken)
Cheers
Danny
Could you please upgrade to 4.7.1.1 to see if that fixed it? It's a patch release so you can just update /bin, /umbraco and /umbraco_client
Jeroen
OK, I updated, but I am still getting an error.
It now doesn't tell me what the error is. It just says "Error loading MacroEngine script (file: Carousel.cshtml)"
That is annoying in it itself, as I can't now easily debug macro scripts!
If you have debugging enabled you can add ?umbDebugShowTrace=true to the url of your page to show the trace which will show the error.
Jeroen
OK, I can confirm that it is the same error was before:
I am not sure why it saying 'string' does not contain, as it should be dynamic XML at this point?
Error Loading Razor Script (file: Carousel) 'string' does not contain a definition for 'url' at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at CallSite.Target(Closure , CallSite , Object )
at ASP._Page_macroScripts_Carousel_cshtml.Execute() in g:\Sites\xxx-xx\xxxx-xxxx\macroScripts\Carousel.cshtml:line 22
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.WebPages.WebPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
I have found a work around that means I can continue, but I think there may be a bug somewhere here, as I can't see why the above methods shouldn't work.
The following however works for me:
I then have to check to see if there are any decendents, and output the result
Note, I have to wrap the XML into root nodes, as the URL Picker doesn't have a root, and I also needed to replace properties that had "-" in them, as these were not accessible with the razer syntax
Hmm I see you are replacing the stripe (-). This is a bug which should have been fixed in Umbraco 4.7.1 http://umbraco.codeplex.com/workitem/30290
Might also be related to this: http://umbraco.codeplex.com/workitem/30680
Not sure if this info is helpful.
Jeroen
Right, issue solved..
I resaved the pages that were added to the releated link collection, and the error went away.
I am only guessing that it hadn't saved correctly to the database?
is working on a reply...