Copied to clipboard

Flag this post as spam?

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


  • Thomas Beckert 176 posts 441 karma points
    Mar 06, 2013 @ 20:56
    Thomas Beckert
    0

    uQuery GetPropertyAs issue

    Why does this code does not work anymore since uQuery get part of the core?

    I also removed any namespace-reference to uComponent, but I does not work anymore since version 4.8

    Error says:

    'umbraco.NodeFactory.Node' does not contain a definition for 'GetPropertyAsString'

    var siteHomeNode = uQuery.GetRootNode().GetChildNodes().FirstOrDefault(node => node.GetPropertyAsString("alias") == "Home");
  • Tom Fulton 2030 posts 4996 karma points c-trib
    Mar 06, 2013 @ 21:43
    Tom Fulton
    0

    Hi Thomas,

    I think those methods have been replaced by the generic method:  GetProperty<string>("alias")

    Hope this helps,
    Tom 

  • Thomas Beckert 176 posts 441 karma points
    Mar 06, 2013 @ 21:52
    Thomas Beckert
    0

    Thank you Tom.

    This gets me one step ahead to the next error. :-)

    Says:

    error CS1502: The best overloaded method match for 'System.Tuple.Create(object, int)' has some invalid arguments

    Error occurs in this line:

     

    <a href='@child.GetProperty<String>("destination")' @Html.Raw(child.GetProperty<Boolean>("newwindow") ? "target=\"_blank\"" : "")>@child.Name</a>

     

    Any idea what this means?

  • Thomas Beckert 176 posts 441 karma points
    Mar 06, 2013 @ 21:54
    Thomas Beckert
    1

    Ok, just fixed it by myself doing this: 

    var url = child.GetProperty<String>("destination");

    <a href='@url' @Html.Raw(child.GetProperty<Boolean>("newwindow") ? "target=\"_blank\"" : "")>@child.Name</a>

                   

    Thank you for the essential hint!

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Mar 06, 2013 @ 22:30
    Tom Fulton
    1

    You got it - Razor trips up with the <> signs.  Another way to get around it is to wrap in parens:

    <a href='@(child.GetProperty<String>("destination"))'> ... </a>
  • 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.

Please Sign in or register to post replies