How To: access custom page properties within a masterpage or page template? (.master/.aspx)

James Borza asked on April 9, 2015 19:39

Is there a current document object or API I can use from within a master page, page template or even web part that will allow me to get the values of the current pages properties? (Kentico 8.2)

I've tried this from within a page template but it doesn't work:

<p><% CurrentPage.GetProperty("BlogDescription"); %></p>

If there is, where is the documentation on this? Also, is there any kind of inherent options? IE: if the blog description property is empty, get the blog description property from the next parent where it isn't.

Thanks!

Recent Answers


Brenden Kehren answered on April 9, 2015 23:55

Since you're using ASPX, you have to manually create all your page templates and inherit them from one another and code what you're looking for. If you were using Portal, you could simply create 2 page templates (within the UI), add a few already created web parts, then inherit the 1st page template from the second one, pretty easy.

0 votesVote for this answer Mark as a Correct answer

James Borza answered on April 10, 2015 00:12

I'm using the aspx + portal page setting. What about within a web part, can I not access the current pages properties from there?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 10, 2015 06:41

Yes you can access the current pages properties using a macro. Within a Transformation you can use a standard C# method or function to get what you need.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.