简体   繁体   中英

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

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" />

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM