I'll post some code shortly but it's the normal default view page code nothing special so far.
@{
var newField = Model.Value("newField");
}
Then I debug the code to see the value but it's empty. What I did notice in debug mode is if I expanded the Children entry when I hover over Model then I can see the child page.
Not sure if that narrows it down? I think I need the code which drills into the children?
Parent DocumentType called Customers (fields called Name and Surname - to make this simple)
I right click and create a new DocumentType called Customer (no S on the end).
Customer has Name and Surname from Customers and i now add Age to Customer (child documenttype).
Under content i create a Customers page and under that i create a Customer page.
My View is simple at present
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
var newField = Model.Value("name");
}
I place a breakpoint on the end and i can see the name i passed in from Umbraco Customers page.
In the Customer page i add the exact same code but for Age
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
var ageField = Model.Value("age");
}
But this time I add an age in an Umbraco (Customer) Page but when that page runs age in the above code is always empty.
So now i go back in debug mode and hover over Model in Visual Studio - when i hover over it i can see a Childrens property and drilling into it through Visual Studio eventually leads me to seeing the value but i dont know how to get to it?
In the back office is your Customer set to use the correct View, it sounds to me like it is using the Customers View so the model getting passed in is not correct.
I think you have something set up incorrectly, could you show a screen shot of your content nodes.
Inherited document type issue
Hi guys
Going through a couple of tutorials. I create a document type. Once created I right click this document type and create a child document type.
I see all the parent fields appear in the child document type. I add a new field on the child only.
In my view page I write the below code
Even though I have filled this in on my page the value does not come through. I did the same code on the parent field and that seems fine.
What's wrong here?
Dean
try
Model.Value("newfield");
(no spaces in alias names)Sorry that was a typo at my end. New field does not contain any spaces.
Thank you
Will need some more info then. What does the config of your child document type look like? What does your View page look like?
I'll post some code shortly but it's the normal default view page code nothing special so far.
Then I debug the code to see the value but it's empty. What I did notice in debug mode is if I expanded the Children entry when I hover over Model then I can see the child page.
Not sure if that narrows it down? I think I need the code which drills into the children?
Without seeing your setup it is dificult to say exactly what you need to do, but it sounds like your view is displaying the parent not the child page
Parent DocumentType called Customers (fields called Name and Surname - to make this simple) I right click and create a new DocumentType called Customer (no S on the end).
Customer has Name and Surname from Customers and i now add Age to Customer (child documenttype).
Under content i create a Customers page and under that i create a Customer page.
My View is simple at present
I place a breakpoint on the end and i can see the name i passed in from Umbraco Customers page.
In the Customer page i add the exact same code but for Age
But this time I add an age in an Umbraco (Customer) Page but when that page runs age in the above code is always empty.
So now i go back in debug mode and hover over Model in Visual Studio - when i hover over it i can see a
Childrens
property and drilling into it through Visual Studio eventually leads me to seeing the value but i dont know how to get to it?In the back office is your Customer set to use the correct View, it sounds to me like it is using the Customers View so the model getting passed in is not correct.
I think you have something set up incorrectly, could you show a screen shot of your content nodes.
is working on a reply...