I have several nested templates, but it seems that I can't apply the controlls to any of the higher templates only the parent of the template that has the <asp:content>
Here are a couple of screen grabs to show you what my template structure is like. I am just trying to add the <asp:content ContentPlaceHolderId = "ankle" runat="server"> to the child template of "News Category". I keep getting an error using the method in the screen captures. Any help would be appreciated. Thanks!
As you said, the page allows only Content controls with the parent's ContentPlaceHolders and not the ancestors ContentPlaceHolders What you need to do is write it like this:
I had to go all the way back up the ancestors, inserting content placeholders, to the "NewsLeftNav" template, that showed the correct location to insert the conten.
I don't understand why it wouldn't show up on those templates that are inbetween "NewsLeftNav" and the actual template where the asp:content was located (NewsCategory) though? Very confused.
If they are optional, then why couldn't I have just placed one ContentPlaceHolder at the template I needed the content injected and then put the content on the nested template I was rendering? Since each template was nested anyway.
I only needed it At "News Category", but the location for placement is not accessable except at the ancestor "News Left Nav". So I placed the ContentPlaceHolder there and "News Internal Page", because if I removed the ContentPlaceHolder from the "News Internal Page" it will not render the "News Category" page. Here is the page with the working "ankle" content at the bottom of the page. http://www.rose-hulman.edu/news/rose-hulman-commencement-2013.aspx
As you can see, naming your controls diffrently is important to the meaning :)
And as I have written this, I see the screenshot and that's what you did. But you needed the content at the place in NewsLeftNav and since the content is several levels below you still need to nest ContentPlaceHolders to let it reach your last page where your content is.
Don't understand what you mean by the earlier pages to make an example. If your still in some trouble, explain a bit further.
Basicly, you just need to add a ContentPlaceHolder on a page so a nested page can use it otherwise it can't display content.
---------------
On your second post:
You can't use a placeholder that you defined on the same template, they are for the nested pages.
You can add the content just above/after the placeholder like this, so a nested page will have the sliderbar + the possibility to add an ankle after that.
So, content is only rendered on the template on which the content is defined? And there has to be a constant nesting back up the template tree (with ContentPlaceHolder) to where the location on the page is that you need the content positioned? I hope I explained this question correctly. Thanks for your help.
Content Placeholders
I have a couple of templates based off a master. I am trying to add content using 'ContentPlaceHolder'. See the last couple of lines:
I have refrenced this in a nested template like this, but I am getting an error previewing the page.
This can't be this difficult. Shouldn't I be able to create this:
As a child of the template of this:
As i've looked into your template I came across this:
You cannot nest content controls, you define your content controls at the same level.
It should look like this:
The content from each Content control will then be injected into the given ContentPlaceHolder.
Also, you defined your content control twice here with the same id.
You only need to define 1 ankle content control
With these changes your templates should be working.
Thanks,
That put the content in the place holder, but I am still confused as to how to get the proper location for my conent within the page?
I have several nested templates, but it seems that I can't apply the controlls to any of the higher templates only the parent of the template that has the <asp:content>
Is that correct?
Here are a couple of screen grabs to show you what my template structure is like. I am just trying to add the <asp:content ContentPlaceHolderId = "ankle" runat="server"> to the child template of "News Category". I keep getting an error using the method in the screen captures. Any help would be appreciated. Thanks!
As you said, the page allows only Content controls with the parent's ContentPlaceHolders and not the ancestors ContentPlaceHolders
What you need to do is write it like this:
Master Page
Nested Master Page
Nested Nested Master's Page
I do suggest to use diffrent ID's to have a better view on what you write:
Master Page
Nested Master Page
Nested Nested Master's Page
I had to go all the way back up the ancestors, inserting content placeholders, to the "NewsLeftNav" template, that showed the correct location to insert the conten.
I don't understand why it wouldn't show up on those templates that are inbetween "NewsLeftNav" and the actual template where the asp:content was located (NewsCategory) though? Very confused.
Also, I thought the ID's needed to be the same?
You didn't get any errors because you didn't define the asp:Content there.
ContentPlaceHolders are optional so some pages implement all content placeholders of parent, some don't.
-----
They don't need to have the same ID to use them.
If they are optional, then why couldn't I have just placed one ContentPlaceHolder at the template I needed the content injected and then put the content on the nested template I was rendering? Since each template was nested anyway.
That's true, you only needed to define it where your nested pages use it.
I assumed that the other templates also needed to use the ankle ContentPlaceHolder so that's why I suggested to nest it all the way up.
When I take the ContentPlaceHolder out of any of the templates that I don't wan't it on it stops rendering the page.
http://www.rose-hulman.edu/news/rose-hulman-commencement-2013.aspx
I only needed it At "News Category", but the location for placement is not accessable except at the ancestor "News Left Nav". So I placed the ContentPlaceHolder there and "News Internal Page", because if I removed the ContentPlaceHolder from the "News Internal Page" it will not render the "News Category" page. Here is the page with the working "ankle" content at the bottom of the page. http://www.rose-hulman.edu/news/rose-hulman-commencement-2013.aspx
I have confused you.
What I ment about placing it where you needed it, was that you only need to define it where you need it like this:
Root Master Page
Nested Master Page
Nested Nested Master Page
Content Page
As you can see, naming your controls diffrently is important to the meaning :)
And as I have written this, I see the screenshot and that's what you did.
But you needed the content at the place in NewsLeftNav and since the content is several levels below you still need to nest ContentPlaceHolders to let it reach your last page where your content is.
Sorry for the confusion.
What I ment by optional I will explain this by an example
Root Master Page
Nested Page
Nested Page 2
As you can see, the root master page has 2 nested pages on the same level, but only 1 defines both placeholders and the other only the body
This will result in
Page 1:
Page 2:
Got it! Thanks for taking the time to explain this to me. I realy appreaciate it!
If I wanted to apply the ankle to one of the earlier pages how would that have looked? Just to make sure I am clearly understanding this.
So you can't inject the content on the same template as where you define the content? Like this?
Don't understand what you mean by the earlier pages to make an example. If your still in some trouble, explain a bit further.
Basicly, you just need to add a ContentPlaceHolder on a page so a nested page can use it otherwise it can't display content.
---------------
On your second post:
You can't use a placeholder that you defined on the same template, they are for the nested pages.
You can add the content just above/after the placeholder like this, so a nested page will have the sliderbar + the possibility to add an ankle after that.
So, content is only rendered on the template on which the content is defined? And there has to be a constant nesting back up the template tree (with ContentPlaceHolder) to where the location on the page is that you need the content positioned? I hope I explained this question correctly. Thanks for your help.
Indeed, content is only rendered on the template where it is defined, like the eample above with the sliderbar.
And there has to be a constant nesting back up the template tree with ContentPlaceHolders & the use of Content controls.
is working on a reply...