Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian Tarrild 23 posts 43 karma points
    Mar 07, 2011 @ 09:02
    Christian Tarrild
    0

    Access custom node properties with Razor

    Hi 

    I have just upgraded from 4.0.4.1 to 4.7RC and started to play around with Razor, but I have problems accessing custom node properties. When I try this (custom property on the node is SiteName)

    @{
     @Model.SiteName
    }

    I get this error on the webpage:

    Error loading Razor Script test.cshtml
    Umbraco Exception (DataLayer): SQL helper exception in ExecuteScalar

    and the trace shows:

    Error Loading Razor Script (file: myTest) Umbraco Exception (DataLayer): SQL helper exception in ExecuteScalar    at umbraco.DataLayer.SqlHelper`1.ExecuteScalar[T](String commandText, IParameter[] parameters)
      at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias)
      at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result)
      at CallSite.Target(Closure , CallSite , Object )
      at ASP._Page_macroScripts_test_cshtml.Execute() in d:\web\localuser\tarrild.dk\test\macroScripts\test.cshtml:line 1
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      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)

    If I try this:

    @{
    @Model.Name
    }

    It works just fine. I have tried with upper and lower case and with different custom node properties. Any ideas? Thanks

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 07, 2011 @ 16:12
    Sebastiaan Janssen
    0

    Should be fairly simple, by the looks of it but I can't quite see it at the moment, what is the exact Alias of the SiteName property? Try changing its name completely, it could be conflicting with something..

    Does this work (using the correct casing of the SiteName alias)?

    @Model.GetProperty("SiteName").Value.ToString()
  • Christian Tarrild 23 posts 43 karma points
    Mar 07, 2011 @ 21:22
    Christian Tarrild
    0

    The alias is SiteName. I have tried with different properties on different document type, but with identical results. When I try

    @Model.GetProperty("SiteName").Value.ToString()

    i get the value of the property with no errors!

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 08, 2011 @ 08:22
    Sebastiaan Janssen
    0

    Hmmm, unfortunately it's quite hard to say what is going wrong, the only thing I can think of right now is debugging the umbraco source and looking at the query that is being performed. 

  • Christian Tarrild 23 posts 43 karma points
    Mar 09, 2011 @ 14:26
    Christian Tarrild
    0

    Hmm, I am only running umbraco hosted at unoeuro so I don't think debugging is possible. I guess the only way foreward is starting from scratch in a clean installation or perhaps wait until the final release of 4.7?

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 09, 2011 @ 17:46
    Sebastiaan Janssen
    0

    Well, it's always a good idea to have a local install first before you deploy, makes it much easier to debug! ;-) It COULD have something to do with your hosting environment, although I can't think what it could be though.

  • Christian Tarrild 23 posts 43 karma points
    Mar 14, 2011 @ 14:36
    Christian Tarrild
    0

    Upgraded to the latest nightly build of umbraco 4.7 which solved the problem.

    Thanks for the help.

Please Sign in or register to post replies

Write your reply to:

Draft