문제

I have a asp.net page (redaktionsplan.aspx), which contains a iframe, which also represent a asp.net-page:

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

test.aspx contains a control (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.

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.

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top