如何在没有母版页的iframe中显示内容

时间:2021-10-29 21:11:29

I have a iframe where it get and display of a page.

我有一个iframe来获取和显示页面。

However if I display the page directly it may contain the header and footer from Master Page.

但是,如果我直接显示页面,它可能包含母版页的页眉和页脚。

My question is can I display only the content of the page without the Master Page in iframe?

我的问题是,我可以只在iframe中显示没有母版页的页面内容吗?

Please give suggestions and advises. Thank you.

请提出建议和建议。谢谢。

2 个解决方案

#1


1  

You could probably pass a parameter into the page (through the querystring for example), which, when set, switches the masterpage to one that is effectively blank (since your page wont work without a masterpage).

您可以将参数传递到页面中(例如通过查询字符串),当设置时,将主页切换为实际为空白的页面(因为您的页面在没有母版页的情况下无法工作)。

So something like this in the Page_PreInit method

在Page_PreInit方法中就是这样的

if (Request.QueryString["iframe"] == "true")
  MasterPageFile = blankMasterPageFile;

#2


2  

Don't set the master page property of the page within the iframe.

不要在iframe中设置页面的母版页属性。

#1


1  

You could probably pass a parameter into the page (through the querystring for example), which, when set, switches the masterpage to one that is effectively blank (since your page wont work without a masterpage).

您可以将参数传递到页面中(例如通过查询字符串),当设置时,将主页切换为实际为空白的页面(因为您的页面在没有母版页的情况下无法工作)。

So something like this in the Page_PreInit method

在Page_PreInit方法中就是这样的

if (Request.QueryString["iframe"] == "true")
  MasterPageFile = blankMasterPageFile;

#2


2  

Don't set the master page property of the page within the iframe.

不要在iframe中设置页面的母版页属性。