Avatar of volking
volking

asked on 

Why does RESIDENT script work but INJECTED script fails?

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?

.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
volking
Avatar of RedKelvin
RedKelvin

Hi,
Can't you simply do a Response.Redirect from the code-behind?
ASKER CERTIFIED SOLUTION
Avatar of RedKelvin
RedKelvin

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of volking
volking

ASKER

@RedKelvin

Nope ... same bad result ... "whatever.aspx" loads ONLY into the frame and NOT THE ENTIRE PAGE!

I've tried ...

Page.RegisterClientScriptBlock("Redirection", "")

and

Page.RegisterClientScriptBlock("Redirection", "")


Avatar of RedKelvin
RedKelvin

I don't think this will provide your answer, but may be of use
http://www.thesitewizard.com/archive/framebreak.shtml

try

Page.RegisterClientScriptBlock("Redirection", "");
Avatar of volking
volking

ASKER

@RedKelvin

Still can't get the two techniques to do the same thing. But, I gave up ...

I created a webpage which OnLoad does the top level redirection and then let the frame page simply call it ...

End result, it takes two hops to get back to the frameless page, but it works ....

Thanks for the help.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo