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
I would like to know if it's possible to check ig a page has specific child nodes. I have something like this:
@{if(Model.someDocName != null && Model.someDocName.Count() > 0){ some code...}
But i keep getting this error: Cannot perform runtime binding on a null reference.
Is it not possible to check for the specific child node or what's the trick to doing so.
What version? I think this is fixed in RC1
I use RC1 with all Razor scripts, but a couple of things bugs me sometimes, this being one of them... :D
In RC1, the return type will be DynamicNull when no property or children exist.
I've checked your syntax and it indeed doesn't work in RC1.
This is because if(Model.someDocName != null [true; DynamicNull != null] && Model.someDocName.Count() [error; .Count doesn't exist on DynamicNull] > 0){ some code...
RC2 is just around the corner, and I have already added support for accessing properties off a DynamicNull
Model.someDocName.Count => DynamicNull
To solve the requirement, i've also added a .Count() function, .IsNull property and .HasValue (reverse of IsNull) property.
This lets your original syntax work.
For now, if you do this:
@using umbraco.MacroEngines
if(Model.someDocType.GetType() != typeof(DynamicNull)){
...
}Then it will behave how you expect in RC1 and RC2
Thanks Gareth
I'll look forward to the next release... :)
I would like to say this was solve, but i can't see the check mark to do so... But i consider it a satisfying answer.
DO' allready marked as solve... My bad...
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Checking for dynamic child nodes
I would like to know if it's possible to check ig a page has specific child nodes. I have something like this:
But i keep getting this error: Cannot perform runtime binding on a null reference.
Is it not possible to check for the specific child node or what's the trick to doing so.
What version? I think this is fixed in RC1
I use RC1 with all Razor scripts, but a couple of things bugs me sometimes, this being one of them... :D
In RC1, the return type will be DynamicNull when no property or children exist.
I've checked your syntax and it indeed doesn't work in RC1.
This is because
if(Model.someDocName != null [true; DynamicNull != null] && Model.someDocName.Count() [error; .Count doesn't exist on DynamicNull] > 0)
{
some code...
RC2 is just around the corner, and I have already added support for accessing properties off a DynamicNull
Model.someDocName.Count => DynamicNull
To solve the requirement, i've also added a .Count() function, .IsNull property and .HasValue (reverse of IsNull) property.
This lets your original syntax work.
For now, if you do this:
@using umbraco.MacroEngines
if(Model.someDocType.GetType() != typeof(DynamicNull))
{
...
}
Then it will behave how you expect in RC1 and RC2
Thanks Gareth
I'll look forward to the next release... :)
I would like to say this was solve, but i can't see the check mark to do so... But i consider it a satisfying answer.
DO' allready marked as solve... My bad...
is working on a reply...