Joby Kurian Joby Kurian - 2 months ago 23
ASP.NET (C#) Question

How to exit from iframe

How to exit from iframe? I have a pages called

Master.aspx
,
Parent.aspx
(inside that iframe is there),
Child.aspx
. I am calling
Child.aspx
inside
Parent.aspx
page using an iframe.

If
strBillingAddress1
is null then I need to redirect to page
Master.aspx
. It is redirecting but showing inside iframe. I don't want this behavior. I need to open as new page itself?

This is the code:

If String.IsNullOrEmpty(Session("strBillingAddress1")) Then
Response.Redirect("Master.aspx")
Response.End()
End If


Plz help me..
Thanks
Joby

Answer

Using the Response.Redirect is impossible to redirect other than self page. The alternative is to use javascript.

Register a client side script that doin the redirect using the location

for example, you can write one of this lines and they do the work.

window.top.location.href= 'theLocation';
window.parent.location.href= 'theLocation';
window.top.location.replace( 'theLocation' );