简体   繁体   English

如何将asp:Content加载到ASPX的子页面中

[英]How to load asp:Content into a subpage in ASPX

I have a master page where I am calling another sub-page using the <asp:Content></asp:Content> 我有一个母版页,使用<asp:Content></asp:Content>调用另一个子页

  • Default.aspx + master = Homepage Default.aspx +主=主页
  • why_choose.aspx + master = Subpage why_choose.aspx + master =子页面

Inside the Subpage I have a menu which other Subpages will also share, so instead of adding the menu in each Subpage, is there any way I can add a <asp:Content></asp:Content> within the Subpage itself to load the menu? 在子页面中,我有一个菜单,其他子页面也将共享该菜单,因此,除了在每个子页面中添加菜单之外,还有什么方法可以在子页面本身中添加<asp:Content></asp:Content>来加载菜单?

If so, how do I do that? 如果是这样,我该怎么做?

try using an iframe element and loading your additional content in it. 尝试使用iframe元素并在其中加载其他内容。

iframe on w3schools W3Schools上的iframe

I think maybe you are misinterpreting master pages. 我认为您可能误解了母版页。

For your described scenario, your master page, generally Site.master should contain your menu markup. 对于您所描述的情况,您的母版页(通常为Site.master应包含您的菜单标记。

Now, any pages you create (Default.aspx, why_choose.aspx) and use your Site.master page will also include your menu, although the markup is not visible within these sub pages. 现在,您创建的任何页面(Default.aspx,why_choose.aspx)和使用Site.master页面都将包含菜单,尽管这些子页面中的标记不可见。

If you want to load some other content into these sub pages, you simply put that new content into the asp:contentplaceholder on the sub pages. 如果要将其他内容加载到这些子页面中,只需将新内容放入子页面上的asp:contentplaceholder

Read up some more on master pages here 此处阅读母版页上的更多内容

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

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