How to fetch document name at page template.

Anand Dev Singh asked on November 11, 2014 09:13

Hi Team,

Am using Kentico v7.0.34.

I have create a page template (Layout type = ASCX) and i want to populate the document name of the page on which the template we will used.

I have tried something like belwo code in the page template code but it haven't worked:

Page Name Is : <%# CurrentPageInfo.DocumentName %>

AND ALSO LIKE

Page Name Is : <%# Eval("DocumentName") %>

Any help will be highly applicable.

Correct Answer

Jan Hermann answered on November 11, 2014 16:19

Hello,

Yes, you can either use <%= CMS.DocumentEngine.DocumentContext.CurrentDocument.DocumentName %> in your ASCX layout, or you can switch to HTML type and use {% CurrentDocument.DocumentName |(identity)GlobalAdministrator%}.

Best regards,
Jan Hermann

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on November 11, 2014 16:01

Try CurrentDocument.DocumentName. This will get the name of the document you are navigating to.

0 votesVote for this answer Mark as a Correct answer

Anand Dev Singh answered on November 12, 2014 04:10 (last edited on December 10, 2019 02:30)

Thanks for your reply.

I have used below codes and its working:

1) <%=CMS.CMSHelper.CMSContext.CurrentDocument.DocumentName%>

2) <%=CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{%CurrentDocument.DocumentName|(identity)GlobalAdministrator%}")%>

0 votesVote for this answer Mark as a Correct answer

Ali Shahrokhi answered on January 21, 2018 23:08

this doesn't work on Kentico 11, would you please provide a solution ?

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on January 21, 2018 23:29

Use the macro approach in the HTML layout type.

0 votesVote for this answer Mark as a Correct answer

Ali Shahrokhi answered on January 22, 2018 00:07 (last edited on January 22, 2018 00:35)

Hi Jan, thank you for the response. I just fixed it. cheers,

0 votesVote for this answer Mark as a Correct answer

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