Output Page DocumentValue

Tom F asked on December 2, 2016 05:23

Really stupid question but I've been dealing with collections and that all makes sense.

If I'm on an aspx page template how do I just spit out field data from the current page? All the basic examples deal with repeaters and transformations. This is driving me nuts! It SHOULD be simple without having to create a whole bunch of tags etc just to spit out a property value..

Correct Answer

Adam Gitin answered on December 2, 2016 05:48

For getting one specific value can use:

CutrentDocument.GetValue("ColumnName")

From Kentico api

1 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on December 2, 2016 11:51

Hi Tom,

Although not recommended you could directly output a macro on a page template by using the the current Resolver:

<%= CMS.MacroEngine.MacroContext.CurrentResolver.ResolveMacros("{%CurrentDateTime%}") %>
<%= CMS.MacroEngine.MacroContext.CurrentResolver.ResolveMacros("{%CurrentDocument.DocumentName%}") %>

I usually just place a static HTML webpart. But in some cases it can be overhead and the above can be cleaner.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 2, 2016 14:11

Tom,

Seems like you've asked more questions than actually reading the documentation and learning the proper way to do things. This question has been answered several times by several people and showing you different ways to do it. Have you checked the documentation on best practices or how to access data?

Both answers above will work and I believe both answers were provided previously. Have you tried either of them previously?

3 votesVote for this answer Mark as a Correct answer

Tom F answered on December 4, 2016 23:54 (last edited on December 4, 2016 23:57)

Thanks guys for the responses.

I'd love to find where in the documentation it lists this kind of stuff. If I had managed to find it in the documentation I wouldn't be asking the questions. Everything seems to be geared at running through transformations and the documentation I've come across hasn't answered my queries.

For example: https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites nothing in there deals with the current document/page?

0 votesVote for this answer Mark as a Correct answer

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