Copied to clipboard

Flag this post as spam?

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


  • Thomas 24 posts 104 karma points
    Sep 25, 2018 @ 09:57
    Thomas
    0

    Get umbraco property value from in umbraco api controller.

    Hi,

    Here i want to get some umbraco content property value and i have tried it to get from umbraco api controller.

    i have tried this by using page id but the page id is always return null.

    Any one please let me know how to handle this?

    thanks, Thomas

  • louisjrdev 107 posts 343 karma points c-trib
    Sep 25, 2018 @ 10:49
    louisjrdev
    0
    [System.Web.Http.HttpPost]
    public GetMyProperty(int nodeId)
    {
        var myNode = Umbraco.TypedContent(nodeId);
        var myProperty = myNode.GetPropertyValue("alias");
        return myProperty;
    }
    

    You may need to return myProperty as Json, in which case you can use Newtonsoft.Json to serialise this easily.

  • Thomas 24 posts 104 karma points
    Sep 25, 2018 @ 11:02
    Thomas
    0

    Thanks Louis

    and i just make a ajax call to GetMyProperty (api controller) to get the property value. In your reply you mentioned nodeId, Could you please tell me how can i get the node id?

  • louisjrdev 107 posts 343 karma points c-trib
    Sep 25, 2018 @ 11:15
    louisjrdev
    0

    Yep exactly, you will probably need to query that from some element in the Html where you store the id (not sure of any potential security issues with that though)

Please Sign in or register to post replies

Write your reply to:

Draft