Hello how to check in Umbraco that node that i get by Id is still exist
var node = new Node(id);
return object in anyway, but if I try read some properties I got exception. Does anyone know Umbraco API function for check it ?
I usually just check:
string.IsNullOrEmpty(node.Name)
A node should never have an empty name, so that way you know it's either unpublished or has been deleted.
It is a workaround for the fact that the API has no other way of checking this.
I use your code to display name of node but when I unpublish it then i have "Error loading Razor Script" . I thought that it will be null.
I use below code in razor macro:
@{
var main = @Model.Down(1);
string value = @main.Name.ToString();
if(!string.IsNullOrEmpty(value)){
@value
}
}
Working perfectly only when node is published
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With