Advertisement

07.17.2008 at 06:30PM PDT, ID: 23575538
[x]
Attachment Details

Why does RESIDENT script work but INJECTED script fails?

Asked by volking in Programming for ASP.NET, .NET Framework 2.0

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?

Start Free Trial
 
Loading Advertisement...
 
[+][-]07.17.2008 at 07:30PM PDT, ID: 22032467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 07:34PM PDT, ID: 22032482

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, .NET Framework 2.0
Sign Up Now!
Solution Provided By: RedKelvin
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.19.2008 at 01:36AM PDT, ID: 22041821

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 04:10AM PDT, ID: 22042176

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:29AM PDT, ID: 22147644

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628