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
Hi.
I'm trying to check if a certain node has a property "footerTextTitle" by:
@foreach (var nodeLink in footerTop.ChildrenAsList.Where(n => n.GetProperty("footerTextTitle").IsNull() == true)) { <li><a href='@nodeLink.GetProperty("footerLinkUrl").Value.ToString()'>@nodeLink.GetProperty("footerLinkTitle").Value.ToString()</a></li> }
and getting a "Object reference not set to an instance of an object." error.
How can I do this ?
olst,
try !string.IsNullOrEmpty(n.footerTextTitle.ToString())
Regards
Ismail
Have a look at the Razor DynamicNode Cheat Sheet. I think you can use these checks:
.HasProperty(string propertyAlias).HasValue(string propertyAlias).IsNull(string propertyAlias)
Jeroen
Have tried code like this
Node somenode = new Node(myNodeID);
if (somenode.GetProperty("myProperty") != null) { string myProperty = somenode.GetProperty("myProperty").Value.ToString(); //Do something with myProperty }
And for an even nicer and simpler and WAY more readable bit of code, try:
@foreach (var item in footerTop.Children.Where("footerTextTitle != null && footerTextTitle.Trim() != string.Empty")) { <li><a href="@item.footerLinkUrl">@item.footerTextTitle</a></li> }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
check if a node has a property
Hi.
I'm trying to check if a certain node has a property "footerTextTitle" by:
and getting a "Object reference not set to an instance of an object." error.
How can I do this ?
olst,
try !string.IsNullOrEmpty(n.footerTextTitle.ToString())
Regards
Ismail
Have a look at the Razor DynamicNode Cheat Sheet. I think you can use these checks:
.HasProperty(string propertyAlias)
.HasValue(string propertyAlias)
.IsNull(string propertyAlias)
Jeroen
Have tried code like this
Node somenode = new Node(myNodeID);
if (somenode.GetProperty("myProperty") != null)
{
string myProperty = somenode.GetProperty("myProperty").Value.ToString();
//Do something with myProperty
}
And for an even nicer and simpler and WAY more readable bit of code, try:
is working on a reply...