I've got a FRAME based application. I'm trying to exit frames and return to a NON frame page. So, from one frame, I want to execute ... parent.top.location.href = "whatever.aspx"
Approach 1 works great, entire page is replaced by no-frames page.
=========================================
Approach 1
=========================================
<script>
function closeFrames()
{
parent.top.location.href = "login.aspx";
}
</script>
=========================================
But Approach 1 must be triggered from inside the markup, which is no good because, I need to do some "cleanup" before the page goes away. So, I need to trigger from code-behind and I try Approach 2,3,4,5 from code behind ... all FOUR approaches DO load "whatever.aspx" ... BUT ... load ONLY into the frame and NOT THE ENTIRE PAGE!
=========================================
Approach 2 - wrap javascript in script tags
=========================================
Dim sb As StringBuilder = New StringBuilder()
sb.Append("<script>")
sb.Append(vbCrLf)
sb.Append("parent.top.location.href = ")
sb.Append(Chr(34))
sb.Append("whatever.aspx")
sb.Append(Chr(34))
sb.Append(";")
sb.Append(vbCrLf)
sb.Append("</script>")
sb.Append(vbCrLf)
Response.Clear()
Response.Write(sb.ToString())
Response.Flush()
=========================================
Approach 3 - call resident javascript from inside script tags
=========================================
Dim sb As StringBuilder = New StringBuilder()
sb.Append("<script>")
sb.Append(vbCrLf)
sb.Append("closeFrames();")
sb.Append(vbCrLf)
sb.Append("</script>")
sb.Append(vbCrLf)
Response.Clear()
Response.Write(sb.ToString())
Response.Flush()
=========================================
Approach 4 - call resident without script tags
=========================================
Dim sb As StringBuilder = New StringBuilder()
sb.Append("closeFrames();")
Response.Clear()
Response.Write(sb.ToString())
Response.Flush()
=========================================
Approach 5 - call javascript literally!
=========================================
sb.Append("parent.top.location.href = ")
sb.Append(Chr(34))
sb.Append("whatever.aspx")
sb.Append(Chr(34))
sb.Append(";")
sb.Append(vbCrLf)
=========================================
I've tried every trick I can think of ... can anyone help?
How do I trigger a NON-FRAME page load from a frame's Code-Behind?
Can't you simply do a Response.Redirect from the code-behind?