Hello,
when I wrote for in the children items .Where(x => x.Content.IsVisible())
I get an error message.
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 23: {
Line 24:
Line 25: @foreach (var subMenu in item.Children.Where(x => x.Content.IsVisible()))
Line 26: {
Line 27:
Source File: e:\Projects\Microsoft\devISKUR v7.8.1\umbISKUR-dev(v7.8.1)\Views\Partials\USNNavigation\USNMainNavigation.cshtml Line: 25
Where am I doing wrong? Can you help me? please.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web;
@using Umbraco.Web.Models;
@using Cogworks.Meganav.Models;
@{
var navigationNodeID = Umbraco.TypedContent(1075);
var test = navigationNodeID.GetPropertyValue("USNMainNavigation");
Cogworks Meganav v1.1.1 Help
Hello, when I wrote for in the children items .Where(x => x.Content.IsVisible()) I get an error message.
Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 23: { Line 24:
Line 25: @foreach (var subMenu in item.Children.Where(x => x.Content.IsVisible())) Line 26: { Line 27: Source File: e:\Projects\Microsoft\devISKUR v7.8.1\umbISKUR-dev(v7.8.1)\Views\Partials\USNNavigation\USNMainNavigation.cshtml Line: 25
Where am I doing wrong? Can you help me? please.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Umbraco.Web; @using Umbraco.Web.Models; @using Cogworks.Meganav.Models; @{ var navigationNodeID = Umbraco.TypedContent(1075); var test = navigationNodeID.GetPropertyValue("USNMainNavigation");
}
Hi Ibrahim,
I think you need to check that Content is set, you might find that it doesn't always have a content node behind it.
So, change your foreach declaration to this:
Thanks,
Nik
Thanks Nik. It's Works.
No problem, pleased it's all sorted for you :-)
Hi! Nik
Can I ask you one more question in this code? If I want to make a 4 Levels navigation, how should I follow a road?
is working on a reply...