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 123 posts 608 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 5908 posts 22603 karma points MVP 4x 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 123 posts 608 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 1505 posts 5911 karma points MVP 4x 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;

  • 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