Change the Source of one Iframe from another

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I know some javascript trick could do this, but I want sth like code-
behind.

I have two iframes and when the user click a button in iframe1, I want
to change the source of iframe2.

For the master page, it is as simple as IFrame2.Attributes["src"]
="mypage.aspx";

But how to do the same thing in IFrame1's Code-behind?
 
Rob said:
I know some javascript trick could do this, but I want sth like code-
behind.

I have two iframes and when the user click a button in iframe1, I want
to change the source of iframe2.

For the master page, it is as simple as IFrame2.Attributes["src"]
="mypage.aspx";

But how to do the same thing in IFrame1's Code-behind?


You will need Javascript to do this.
The IFrame1's Code-Behind runs at the server when you submit the Form
inside IFrame1. This will only send back to the browser the content that is
to be loaded inside the IFrame1. The page that contains that IFrame is
unaffected, it does not receive anything from the server, so the src of the
IFrame2 will remain set to its previous value regardless of whatever you
send back from the code-behind of the page loaded inside IFrame1.
On the other hand, the browser does see the container page and both
iframes, and can process changes in any of them, so it may be possible to
achieve the effect that you want by playing around a bit with javascript.
 
Back
Top