How do I pass a QueryString value to an iFrame?

cdemott33
cdemott33 used Ask the Experts™
on
Hi Team-

I could use some help here.  I have a classic ASP page that uses a iFrame.  The iFrame loads an ASP.NET page on another server.  

When my classic ASP page loads there's a QueryString value I need for my IFrame page to load correctly.

How do I pass a QueryString value to my iFrame so my ASPX page can read the value?

So here an example of my Classic ASP page URL:

http://www.myclassicasp.com/myform.asp?intakeID=12345678

Here's my iframe in my Classic ASP page:

<iframe id="myIframe" src="http://myaspxapplication.com/IntakeUpload.aspx" width="100%" frameborder="0">
</iframe>

Open in new window


Here's my code behind on my IntakeUpload.aspx page (The page that's getting loaded into my iFrame)

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim intIntakeID As Nullable(Of Integer) = CInt(Request.QueryString("intakeID"))

        If intIntakeID.HasValue Then
            lbIntakeID.Text = "No Intake ID found"
        Else
            lbIntakeID.Text = intIntakeID.ToString
        End If

    End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Web Ninja at large
Commented:
try this:

<iframe id="myIframe" src="http://myaspxapplication.com/IntakeUpload.aspx?intakeID=<%=Request.QueryString("intakeID")%>" width="100%" frameborder="0">
</iframe>
Paul MacDonaldDirector, Information Systems

Commented:
[Big Monty]'s example pulls the parent page AS the iframe, and I don't think that's right.  You need to pull the iframe, but call the querystring from the parent.

<iframe id="myIframe" src="http://myaspxapplication.com/myIframe.aspx?intakeID=<%=Request.QueryString("intakeID")%>" width="100%" frameborder="0">
</iframe>

Per:
http://stackoverflow.com/questions/15918480/read-query-string-parameters-from-inside-iframe

http://www.codeproject.com/Questions/500140/AccessplusQueryStringplusToplusparantpluspage-cpl

Author

Commented:
Thank you.  This worked!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial