Unable to get values out of a node from code behind

mun yung kan asked on November 30, 2015 11:45

Hi Guys,

i'm facing a problem trying to get some values from a node.

my pages in kentico all inherit from a BasePage type.

in this base page type, there are 3 fields, "TeaserTitle" "TeaserDescription" "TeaserImage"

when i try something like:

var child = CMS.DocumentEngine.DocumentContext.CurrentDocument.Children.First();

var teaserTitle = child.GetValue<string>("TeaserTitle","");

It returns an empty string, even though the i've entered the values in the form editor for the page.

is there something fundamental about the way kentico retrieves field data that i don't understand?

Correct Answer

Dawid Jachnik answered on November 30, 2015 13:32



it doesn't return data of your custom type. You need to do it in this way:

4 votesVote for this answer Unmark Correct answer

Recent Answers

mun yung kan answered on December 1, 2015 02:28

Thanks Dawid, that did it!

i'm guessing kentico returns a bare minimum of information unless you specifically request for all of it?

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on December 1, 2015 06:02


that's right. Quote from documentation:

"Through its Children property, the system then accesses a collection containing all child pages. Using     the WithAllData property ensures that the retrieved page objects include their coupled data, i.e. the specific  fields defined for the given page type."
2 votesVote for this answer Mark as a Correct answer

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