SaaS CMS has officially launched! Learn more now.

How to get the pagetype property description/caption


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:


This is the text for the first  property


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.



Dec 08, 2011 16:50

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;

Edited, Dec 08, 2011 20:21

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?


Dec 09, 2011 9:18

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.

Dec 09, 2011 10:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.