I have the DocumentType Page which is allowed to have TextSection and ImageSection. Each DocumentType has its own template.
So there is Page.cshtml, TextSection.cshtml, ImageSection.cshtml.
My Page.cshtml looks like this:
@foreach (var child in Model.Content.Children())
{
@Umbraco.RenderTemplate(child.Id)
}
My Page.cshtml uses the MasterTemplate.cshtml as Layout file and contains a section called JS. MasterTemplate.cshtml calls the RenderBody method to render the content of Page.cshtml.
From within Page.cshtml I can write to the JS section. But from within TextSection and ImageSection I can't. I don't get any errors but it's just not written to the section. I assume this doesn't work because I'm not using the Layout tag on the Section Templates.
This is a .Net MVC issue where sub views cannot use the section notations. As of yet, I've not been able to find a work around for that is effective and it annoys me.
I would love it if someone had a decent solution for this as well!
Writing Code to section from RenderTemplate
I have the DocumentType
Pagewhich is allowed to haveTextSectionandImageSection. Each DocumentType has its own template.So there is
Page.cshtml,TextSection.cshtml,ImageSection.cshtml.My
Page.cshtmllooks like this:My
Page.cshtmluses theMasterTemplate.cshtmlas Layout file and contains a section called JS.MasterTemplate.cshtmlcalls theRenderBodymethod to render the content ofPage.cshtml.From within
Page.cshtmlI can write to the JS section. But from withinTextSectionandImageSectionI can't. I don't get any errors but it's just not written to the section. I assume this doesn't work because I'm not using the Layout tag on the Section Templates.How do I resolve this problem?
This is a .Net MVC issue where sub views cannot use the section notations. As of yet, I've not been able to find a work around for that is effective and it annoys me.
I would love it if someone had a decent solution for this as well!
RenderTemplate is a method to be avoided, according to this!
Perhaps this strategy will work with:
?
Check this out!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.