Copied to clipboard

Flag this post as spam?

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


  • Ambert van Unen 54 posts 96 karma points
    Nov 11, 2015 @ 10:47
    Ambert van Unen
    0

    GetPropertyValue<> fails (U 7.3)

    Hi,

    I'm working in a new install of Umbraco 7.3. And in previous versions I could always this for example:

    string key = Model.Content.GetPropertyValue<string>("key");
    

    Only when I'm currently trying to use it, i get the following error in Visual Studio:

    Cannot convert method group 'GetPropertyValue' to non-delegate type 'object'. Did you intend to invoke the method?  
    

    And when I run the website I'm receiving a parser error. Did something change? Could it be related to MVC5? This is currently a very simple page, using the following code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
        var page = @CurrentPage.Site();
    }
    
    <!DOCTYPE html>
    <html lang="en">
      <head>
    
    
      </head>
    
      <body>
    
        @Model.Content.GetPropertyValue<string>("key")
    
      </body>
    </html>
    

    Update: This only occurs when using in a template file, when using this in a partial, or in a helperextension.cs for example. It does work.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Nov 11, 2015 @ 13:23
    Jeavon Leopold
    100

    You need to add brackets to your code due to the type <>, e.g.

    @(Model.Content.GetPropertyValue<string>("contentVoorwaarden"))
    
  • Ambert van Unen 54 posts 96 karma points
    Nov 11, 2015 @ 13:28
    Ambert van Unen
    0

    That was it... Never had to do that before, this is only needed in a template file as far as I can tell.

      @(Model.Content.GetPropertyValue<string>("key"))
    

    Just don't understand why, yet. Maybe something to do with the template parsing the <string> as HTML ?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Nov 11, 2015 @ 13:30
    Jeavon Leopold
    0

    Yes, if you have a type in angle brackets such as < string > you need the additional brackets for the parser to work

  • 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