母版页可以引用具有相同内容和 contentplaceholder 标记的另一个母版页吗?
当前设置
我目前在以下层次结构中拥有三个母版页和内容页:
- 一个显示最终结果的根级母版页。将此称为“A”
- 两个兄弟页面不互相引用,但包含所有相同的 contentplaceholder 元素,只是顺序不同,周围有不同的
。两者都引用根级主页。将它们称为“B1”和“B2”。
- 引用上述一个或其他同级母版页(不是两者)的多个内容页。将这些称为“C1”到“C-随便”。
基本上我有:
Cn =>; B1 =>一个
厘米=> B2 =>一个
这个层次结构工作得很好。
所需的设置
我想要做的是在内容页面和同级母版页之间的层次结构中添加一个新级别(新的母版页)。基本上是这样的:
- 一个显示最终结果的根级母版页。
- 两个同级页面加上第三个同级页面。将其称为 B3
- 新的中间母版页,它动态“选择”同级母版页之一。期望的行为是将 C 给出的内容直接传递给 Bn 而不对其进行修改。 D 唯一主动做的就是选择哪个 Bn。将此新母版页称为 D。
- 几个内容页面引用新的中间母版页而不是旧的同级页。
对此的挑战是,我正在一个相当复杂的产品范围内工作,并且我无法更改原始的两个同级母版页(B1 和 B2)或内容页面( C)以任何有意义的方式。
我想:
Cn =>; D=> B1=>一个
厘米=> D=> B2 =>一个
CK => D=> B3 =>一个
本质上,D 应该将其所有内容“传递”到它选择的任何 B 级母版页。我无法将这个逻辑放在 C 级页面中。
其他详细信息
- 所有 B 级页面都具有相同的内容/内容占位符标签,只是顺序和样式不同。
- D 可以很复杂,只要它不需要修改 C 或 B。
- 我正在使用 ASP.Net 2.0
这可能吗?
Current Setup
I currently have three masterpages and content pages in the following hierarchy :
- One root-level masterpage that displays the final result. Call this "A"
- Two sibling pages that don't reference each other but contain all the same contentplaceholder elements, just in a different order with different
<div>
's surrounding them. Both reference the root-level masterpage. Call these "B1" and "B2". - Several content pages that reference one or the other sibling master pages above (not both). Call these "C1" through "C-whatever".
Basically I have:
Cn => B1 => A
Cm => B2 => A
This hierarchy works fine.
Desired Setup
What I want to do is add in a new level to this hierarchy (a new master page) between the content pages and the sibling masterpages. Basically so it's like this:
- One root-level masterpage that displays the final result.
- Two sibling pages plus a third sibling. Call it B3
- A new middle masterpage that dynamically 'chooses' one of the sibling masterpages. The desired behaviour is to pass through the content given by C directly to Bn without modifying it. The only thing D actively does is choose which Bn. Call this new masterpage D.
- Several content pages that reference the new middle master page instead of the old siblings.
The challenge to this is, I'm working within the confines of a rather complex product and I cannot change the original two sibling masterpages (B1 and B2) or content pages (C) in any meaningful way.
I want:
Cn => D => B1 => A
Cm => D => B2 => A
Ck => D => B3 => A
Essentially, D should "pass through" all it's content to whichever B-level masterpage it chooses. I can't put this logic in the C-level pages.
Additional Details
- All B-level pages have the same content/contentplaceholder tags, just ordered and styled differently.
- D can be as convoluted as it has to be, so long as it doesn't require modifying C or B.
- I'm using ASP.Net 2.0
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MasterPage 没有 Page_PreInit 事件,因此对 MasterPage 层次结构(嵌套或其他方式)的所有更改都必须源自内容页。
因此,如果您可以修改内容页面,请添加:
A MasterPage doesn't have a Page_PreInit event, so all changes to the MasterPage hierarchy (nested or otherwise) must originate from the content page.
So, if you can modify the content pages, add: