I'd like to say that this is quite an unorthodox solution because the display name/caption is set in admin mode by an administrator while the content is set by the editor. I would say it is more common to keep the "heading" in a separate string property for the editor to set.
If you still want to get the values displayed in edit mode, you should get the PropertyData from the page using something like this:
var propertyData = CurrentPage.Property["MyProperty"];
var propertyDefinition = PageDefinition.Load(propertyData.PageDefinitionID);
var caption = propertyDefinition.EditCaption;
Hi Magnus.
Thank you for your reply.
You say: "If you still want to get the values displayed in edit mode"
What I want is to show these caption/descriptions in the published text, both to visually separate the different texts and to let the reader know in which context the text is written. These xhtml texts can be seen as metadata describing the "main content" of the page. This means that the field "Purpose" will always be purpose so there is no need for the editor to add this description each time a new page of this pagtype is created.
Is this making any sence?
If so will your approach be the same?
Petter
Well, it's no crime to use the propertyDefinition to get the caption :)
But if the headings for these metadata are always the same then I think the more common solution would be to code the headings into the page template using the Translate control / Translate method to get them from a language file, keeping the text displayed to editors and to visitors separate.
I'm totally new to both Episerver and ASP.NET/C# so the question might be a little unclear...
I have started with adjusting on a page template and have succeeded so far, but it would be nice to fix some small details:
I have added several xhtml properties (fields? - unsure of the correct term...) that are diplayed one after the other in a column. At the beginning of each property/text, I would like to display the name/caption of the property as shown in admin/pagetype for the value, but only if the property contains something.
Something like this:
Myfield1
This is the text for the first property
Myfield2
This is the text for the second property
Myfield1 and Myfield2 are the name/captions/fieldname for the property
Being av newbie - a code example would be very nice.
Regards
Petter