简体   繁体   English

直接在包含内容控件的内容页面中仅允许内容控件

[英]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. 母版页是从另一个母版页继承而来的,子母版的许多ContentPlaceHolders都包裹在Content标记中,这些标记将来自继承页的内容注入父母版的占位符。 However, I want the child master to deviate a little from the base master, but having its own ContentPlaceHolder unrelated to the parent master. 但是,我希望子母版与基本母版稍有不同,但是要拥有自己的ContentPlaceHolder与父母版无关。 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? 如果放置了独立的ContentPlaceHolder,则父母版页如何知道将其内容放置在何处?

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. 您必须在父级中选择一个ContentPlaceHolder才能将其添加到其中。
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. 如果出于定位目的而执行此操作,则可以使用CSS在呈现页面上的任何位置定位该div的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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