Get IFrame Reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I get the reference of the IFrame from the asp.net webpage that is
being displayed within that IFrame? In other words I have an IFrame in my
page. Within that IFrame Set the source to a different asp.net page. I want
on that page that is within the IFrame to be able to access the IFrame
object. How can that be done? Besides the reference to the IFrame but also
certain other objects that are in the Host page of the Iframe.

thanks in advance...
 
No not at all. I do not want to do anything with changing the source. I need
to within the ASP.NET page that is within the IFrame to be able to Hide the
Iframe (which is the parent) when the User clicks a button. Thats it.... How
do I do this?

thanks
 
If you want the page that's within the IFrame to be redirected just redirect
from that page... it will happen automatically and stay in the IFrame.
Now if you are saying you want the page that's inside the IFrame to redirect
the PARENT page you'll have to use Javascript to get the Parent ID.
Same from the Parent, to change the SRC for the IFrame.
 
Hi Angel,

If you want to hide the frame you should declare the frame as a server
control by adding a runat="server" attribute to the iframe control and
assign it an ID.

<iframe id="myFrame" runat="server" src="Default.aspx" style="WIDTH:
616px; HEIGHT: 224px"></iframe>

On your page within the iFrame, you create a button (e.g. btnHideFrame)
which fires a client side event when clicked (this will hide the frame).

On your Page Load...
btnHideFrame.Attributes.Add("onclick", "HideFrame();");

Then on your .aspx, add the codes below to handle the button's client-side
click event

<script>
function HideFrame()
{
window.parent.document.all["myFrame"].style.display = "NONE";
}
</script>

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top