How to render a form field on a template

Thomas Seyssens asked on May 9, 2016 13:06

Hello,

I'm trying to find out the syntax to render a field on every page that is inheritting from a template. I want to make sure every page automatically fills in the title. To achieve that, i want to add the field in my template. in that case, every page that inherits from this page, automatically has this title field. The template is an ASCX format.

For example:

<div class="sample classes">
      <h2>Sample sample -- I NEED MY PAGETITLE HERE -- </h2>
</div>

Correct Answer

Joshua Adams answered on May 9, 2016 15:29

I believe currentdocument has a get value field. Try this:

<%= CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("Title") %>

Also, not sure but it may take an override with a default value:

<%= CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("Title","") %>

3 votesVote for this answer Unmark Correct answer

Recent Answers


Joshua Adams answered on May 9, 2016 15:24

Something like this should work

<%= CMS.DocumentEngine.DocumentContext.CurrentDocument.DocumentName %>

0 votesVote for this answer Mark as a Correct answer

Thomas Seyssens answered on May 9, 2016 15:26

Hello Joshua,

When using this line, it would use the DocumentName, which looks like the item-name in Kentico? I actually need a defined field on the page type, called "Title".

Any idea on how i can get this field?

0 votesVote for this answer Mark as a Correct answer

Thomas Seyssens answered on May 9, 2016 15:59

Hi Joshua,

I managed to fix it. Your help got me on the right way! When i used this: <%= CMS.DocumentEngine.DocumentContext.CurrentDocument["Title"] %> Thank you for the help!

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on May 9, 2016 17:30

Glad you figured it out!

0 votesVote for this answer Mark as a Correct answer

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