简体   繁体   English

iframe中父页面的访问控制

[英]Access Control of parent page in iframe

I have a asp.net page (redaktionsplan.aspx), which contains a iframe, which also represent a asp.net-page: 我有一个asp.net页(redaktionsplan.aspx),其中包含一个iframe,它也代表一个asp.net页:

<iframe src='test.aspx' height="1000px" width="700px" frameborder="0">

test.aspx contains a control (label1). test.aspx包含一个控件(label1)。 Now, I want in the OnLoad-Event of the label1 (which is on test.aspx) (in CodeBehind of the label1) access a control which is on redaktionsplan.aspx. 现在,我想在label1的OnLoad-Event中(位于test.aspx上)(位于label1的CodeBehind中)访问redaktionsplan.aspx上的控件。

How is this possible? 这怎么可能?

You cannot access controls of another page on the server. 您无法访问服务器上另一个页面的控件。

The two pages are requested by the browser with two separate HTTP GET requests: the first one for redaktionsplan.aspx, then when that page is rendered in the browser, another request is made for test.aspx. 浏览器使用两个单独的HTTP GET请求来请求这两个页面:第一个用于redaktionsplan.aspx,然后在浏览器中呈现该页面时,另一个请求用于test.aspx。

So the code-behind on these two pages runs sequentially (not at the same time) and in the context of two different requests. 因此,这两个页面上的后台代码顺序运行(而不是同时运行),并且在两个不同的请求的上下文中运行。

If you need to exchange data between two pages, then you can for example: 如果需要在两个页面之间交换数据,则可以例如:

  • let the first page store the data in the session, so that during the second request you can access it 让第一页将数据存储在会话中,以便在第二个请求期间可以访问它
  • implement the functionality on the client side, using javascript 使用javascript在客户端实现功能

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

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