Hi all i was wondering if its possible to get the page name in c#? I need it to build a string with the page name in it, which i'm doing all in a template using c# code behind!
Use the umbraco.presentation.nodeFactory.Node.GetCurrent() method like Petr describes, and the Name property.
Node node = umbraco.presentation.nodeFactory.Node.GetCurrent(); string name = node.Name;
The reason for this is that Node uses the data that is cached, while Document actually makes an SQL call to the database, so only use it when you need to change the data in some way.
PageName in c# code behind?
Hi all i was wondering if its possible to get the page name in c#? I need it to build a string with the page name in it, which i'm doing all in a template using c# code behind!
Look at properties of Node and use umbraco.presentation.nodeFactory.Node.GetCurrent() to get current node
http://en.wikibooks.org/wiki/Umbraco/Samples_and_Articles/Dot_Net_Controls/Access_Umbraco_Data_With_Dot_NET_Controls
P.
Hi Vincent,
Have a read over the wiki articles for the API, specifically the nodeFactory and Document classes/objects:
http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory
http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-a-node-and-a-document
Quick example:
Cheers, Lee.
Use the umbraco.presentation.nodeFactory.Node.GetCurrent() method like Petr describes, and the Name property.
The reason for this is that Node uses the data that is cached, while Document actually makes an SQL call to the database, so only use it when you need to change the data in some way.
Hope this helps.
Frederik
... or if you need to access unpublished content.
is working on a reply...