I'm trying to setup my templates such that pages render the document name onto the Page banner section. Here is my code on the page template:
<div class="row show-grid"> <div class="col-md-12 page-banner"> <span class="show-grid-block"> <img src="/happy-tails/media/Assets/Images/dog-beagle.jpg" style="width: 100%; height: auto;"> <h1 class="page-title"> <%= CMSContext.CurrentDocument.DocumentName %> </h1> </span> </div> </div>
It works on most of my pages but I have a specific template being used by 2 pages that gives this server error when I apply the above:
There was an error processing the page. The error can be caused by the configuration of some component on the master page. Check the master page configuration or see event log for more details. Original message: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %).
Anyone have any ideas why this is happening? Thanks!
Hi,
This depends on the order when this code is loaded. It depends what other web parts are on the page. Since it is not possible to ensure the same loading order all the time, the solution is described in this article.
Best regards, Juraj Ondrus
If you wrap your code in an <asp:PlaceHolder /> control, it will fix the issue.
<asp:PlaceHolder />
By using the placeholder, like Tim says, it resolved the issue for me.
Please, sign in to be able to submit a new answer.