Search In
Learn from 350 other Umbracians at the annual Umbraco Conference - CodeGarden '13. More than twenty high quality sessions, open spaces, hackathons and social events you'll remember. Not to be missed! Less than 25 tickets left - get yours now!
Hi,
Does anyone know how to get the Name (not alias) of a property in Razor?
thanks,
Matt
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! :)
Oops looks like I've misread your post!
It's just Name, e.g.
DynamicModel.Children.First().ContentType.Name
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") } </textarea> }
This forum really doesn't like you pasting code in