Umbraco Razor - One Way to Check to See if A Node or Page Still Exists and or is Published


This can be used, for example, in a Partial View to see if a node is publish and or exists to ensure that the page does not throw an error when trying to write out details from a page or it's sub nodes .


@{
var thisPage = Umbraco.Content(1256); // Get the page
}

@if(thisPage.Path != null && thisPage.Path != "")
{
   // Write out content from that page

 }

Comments

Popular posts from this blog

Umbraco - Reset the Admin Password via SQL Server

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version