Copied to clipboard

Flag this post as spam?

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

  • Matt Nolan 45 posts 65 karma points
    Feb 29, 2012 @ 18:26
    Matt Nolan

    Get property name


    Does anyone know how to get the Name (not alias) of a property in Razor?



  • Braydie 141 posts 279 karma points
    Mar 02, 2012 @ 15:57

    Hi Matt,

    If you are using a dynamic node you can just @MyDynamicNode.MyPropertyAlias and access it like that, or if you are using a regular Node, then you would do @MyNode.GetProperty("MyPropertyAlias")

    It's something like that! Hope I've pointed you in the right direction at least! :)

  • Braydie 141 posts 279 karma points
    Mar 02, 2012 @ 16:03

    Oops looks like I've misread your post!

  • Chris S. 113 posts 22 karma points
    Mar 02, 2012 @ 16:50
    Chris S.

    It's just Name, e.g.


    If you want to see all of them, you could try:


    @foreach (var child in DynamicModel.Children)
        <textarea rows="40" cols="40"> 
    @foreach(PropertyDescriptor descriptor in TypeDescriptor.GetProperties(child.ContentType)) 
    string name=descriptor.Name; 
    object value=descriptor.GetValue(child.ContentType); 
    @Html.Raw(name + "=" + value +"\n") } 

    This forum really doesn't like you pasting code in

  • zedna 7 posts 87 karma points
    Sep 24, 2015 @ 06:51

    This doesn´t work when you need Name of Property

     foreach (var item in list)
                var proplist = item.Properties;
                foreach (var prop in proplist)
                    <li>@prop.PropertyTypeAlias (@prop.Name)</li>

    prop.Name doesn´t work in this case, but name is written somewhere in database. Can i uncover this field to be able to display it?

  • Eran Schoellhorn 3 posts 73 karma points
    Dec 07, 2015 @ 15:01
    Eran Schoellhorn

    Howdy Zedna -- Did you have any success in accessing a property's name? I'm having the same issue...

    So weird that it's not included with the actual property...

  • Eran Schoellhorn 3 posts 73 karma points
    Dec 09, 2015 @ 12:03
    Eran Schoellhorn

    Just wanted to followup on this as I've finally got a solution in place, hopefully this helps someone who lands in the same boat as I have been the past few days.

    So my issue has been that the Properties list present on nodes returned from Umbraco.Content(whatever).Children contained property values and their respective aliases but did not contain the actual name/label of the property.

    I found that a lookup must be performed on the node's content type, the result here was an object that contained both the alias and name!

    Here's the relevant code that's worked for me. Note: I opted to create a dictionary to output my property names where needed.

      int ContentTypeId; // ex: [YourUmbracoNode].ContentType.Id 
      var cts = ApplicationContext.Current.Services.ContentTypeService;
      var ct = cts.GetContentType(ContentTypeId);
      Dictionary<string, string> propMap = new Dictionary<string, string>();
      foreach (var propertyType in ct.PropertyTypes)
        propMap.Add(propertyType.Alias, propertyType.Name);

    Hopefully this helps someone out there.


    Hobbled together from these other, related, threads:

Please Sign in or register to post replies

Write your reply to:

Draft is the community mothership for Umbraco, the open source cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.5.4