Only Content controls are allowed directly in a content page that contains Content controls

∥☆過路亽.° 提交于 2019-12-10 15:32:53

问题


I'm trying to add a content place holder into a master page but getting the above error. The master page inherits itself from another master page and many of the ContentPlaceHolders of the child master are wrapped in Content tags which inject the content from the inheriting page into the place holders of the parent master. However, I want the child master to deviate a little from the base master, but having its own ContentPlaceHolder unrelated to the parent master. Yet it seems to not like having the following line:

<asp:ContentPlaceHolder ID="chpBanner" runat="server" />

回答1:


That is not possible. It does not even make logical sense.
If you placed an independent ContentPlaceHolder how would the parent master page know where to put the contents of it?

How would it build the control tree, if there was no parent to attach the controls to?

You will have to select a ContentPlaceHolder in the parent to add it to.
If you are doing this for positioning purposes, you can use CSS to position the contents of this div whereever you want on the rendered page.



来源:https://stackoverflow.com/questions/12265119/only-content-controls-are-allowed-directly-in-a-content-page-that-contains-conte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!