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 Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

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