Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
<%= umbraco.library.GetDictionaryItem("dictionaryname") %> that code works,
so im wondering if there is a similar one, that can pull out current page name?
<%= umbraco.library.GetSomething %>
which would result in
content of dictionary item and then page name written out.
Hi Martin
Alot will depend on which version of Umbraco you are using: If you make your usercontrol inherit from the special class UmbracoUserControl
public partial class MyLovelyUserControl : UmbracoUserControl
Then you will have access to all the Umbraco Helper Methods
https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/
and so in your User Control ascx portion you will be able to write:
<%@ Import Namespace="Umbraco.Web" %> <% var currentPageId = UmbracoContext.Current.PageId; var currentPage = Umbraco.TypedContent(currentPageId); %> <h1><%=currentPage.Name %></h1>
The currentPage returned above is of IPublishedContent type; you can read about all the available properties on IPublishedContent here:
https://our.umbraco.org/documentation/Reference/Querying/IPublishedContent/Properties
If the site is an older version of Umbraco and doesn't have IPublished content etc then if memory serves me correctly the way to get the current node from the content cache in a user control is to use Umbraco NodeFactory eg:
<%@ Import Namespace="umbraco.NodeFactory" %> <% var currentNode = Node.GetCurrent(); %> <h2><%=currentNode.Name %></h2>
regards
Marc
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
how do i print out the page name from an ascx file?
<%= umbraco.library.GetDictionaryItem("dictionaryname") %> that code works,
so im wondering if there is a similar one, that can pull out current page name?
<%= umbraco.library.GetSomething %>
which would result in
content of dictionary item and then page name written out.
Hi Martin
Alot will depend on which version of Umbraco you are using: If you make your usercontrol inherit from the special class UmbracoUserControl
Then you will have access to all the Umbraco Helper Methods
https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/
and so in your User Control ascx portion you will be able to write:
The currentPage returned above is of IPublishedContent type; you can read about all the available properties on IPublishedContent here:
https://our.umbraco.org/documentation/Reference/Querying/IPublishedContent/Properties
If the site is an older version of Umbraco and doesn't have IPublished content etc then if memory serves me correctly the way to get the current node from the content cache in a user control is to use Umbraco NodeFactory eg:
regards
Marc
is working on a reply...