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 guys,
I'm fairly new to umbraco and c#, and i'm trying to get children and properties of the children of a specific node,
but i returns 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeById'
Here is the code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@ {
Layout = null;
foreach (var page in Model.NodeById(1000).Children.Where(i => i.IsVisible())){
// do something
}
What am i missing? Any assistance would be appreciated
Yes you are trying to call NodeById but method does not exsist
What are you trying to do?
@{
Layout = "this should be your masterpage and not null
Your model will be the node in the context of the current page.
So if i am on the home node the Model will be the home node.
so i could do things like
@Model.GetPropertyValue("your alias").value;
or
@Model.Name (for the name of the node)
Post again if you need more help :).
var content = new UmbracoHelper(UmbracoContext.Current).TypedContent(nodeId);//Replace nodeId with node Id that you requireSo I would hope, but not tested @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
foreach (var page in (new UmbracoHelper(UmbracoContext.Current).TypedContent(1000)).Children.Where(i => i.IsVisible())){
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
'Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeById'
Hi guys,
I'm fairly new to umbraco and c#, and i'm trying to get children and properties of the children of a specific node,
but i returns 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeById'
Here is the code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@ {
Layout = null;
foreach (var page in Model.NodeById(1000).Children.Where(i => i.IsVisible())){
// do something
}
}
What am i missing? Any assistance would be appreciated
Yes you are trying to call NodeById but method does not exsist
What are you trying to do?
@{
Layout = "this should be your masterpage and not null
}
Your model will be the node in the context of the current page.
So if i am on the home node the Model will be the home node.
so i could do things like
@Model.GetPropertyValue("your alias").value;
or
@Model.Name (for the name of the node)
Post again if you need more help :).
var content = new UmbracoHelper(UmbracoContext.Current).TypedContent(nodeId);//Replace nodeId with node Id that you require
So I would hope, but not tested
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@ {
Layout = null;
foreach (var page in (new UmbracoHelper(UmbracoContext.Current).TypedContent(1000)).Children.Where(i => i.IsVisible())){
// do something
}
}
is working on a reply...