Copied to clipboard

Flag this post as spam?

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


  • Roger Withnell 128 posts 613 karma points
    Aug 10, 2016 @ 20:52
    Roger Withnell
    1

    Get a member's custom property

    How do I get the value of a custom property of type true/false?

    I have manually set it to true.

    I am using MVC Raxor and I get the member with:

    var vMember = Members.GetCurrentMember();
    

    In debug, I can see the custom property (by examining vMember) in Properties > Umbraco.Core.Models.IPublishedProperty[0].

    According to Intellisense, "HasValue" and "GetPropertyValue" are not available and "GetProperty("customProperty").Value gives an error.

    Your help would be much appreciated.

    Thanking you in anticipation.

    Roger

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Aug 10, 2016 @ 21:06
    Alex Skrypnyk
    0

    Hi Roger,

    It works fine:

    var vMember = Members.GetCurrentMember();
    
    var testValue = vMember.GetPropertyValue("testValue");
    

    What version of Umbraco are you using?

    Thanks,

    Alex

  • Roger Withnell 128 posts 613 karma points
    Aug 10, 2016 @ 21:14
    Roger Withnell
    0

    Thanks Alex, but no joy.

    var testValue = vMember.GetPropertyValue("myCustomProperty");
    

    has the error: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'GetPropertyValue' and no extension method 'GetPropertyValue' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

    I'm using 7.2.8.

    Any thoughts?

    Roger

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 10, 2016 @ 21:18
    Dan Diplo
    101

    Be sure you are using the namespace Umbraco.Web to get the GetPropertyValue extension methods.

    ie. in a view add @using Umbraco.Web or in a class using Umbraco.Web;

Please Sign in or register to post replies

Write your reply to:

Draft