This is a migrated thread and some comments may be shown as answers.

GetRadWindow() null after postback from iFrame?

6 Answers 108 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 16 Jan 2013, 05:38 PM
Here is my scenario:

 - The user is on an order page - enters a new order
 - Upon completion, a RadWindow is displayed confirming your order was entered
 - From this first RadWindow you can click on a button to apply payment
 - This opens a second RadWindow which asks for Payment Information
 - If you select to pay via Credit Card, this opens a third RadWindow to collect the CC details from an external site inside an iFrame

At this point all is good.

Now, when you are done processing the CC payment in the third RadWindow
, the processor's page fires a refresh target=_self, which ends up being the third RadWindow, appending a value to the query string to indicate that it has finished.  I then can read out some variables from Request.Params to see if the payment took, etc.

The Problem:

When I first open the RadWindow, I can call the GetRadWindow() function and I get the reference to the Third RadWindow.  BUT when the processor page (which is in an iFrame) refreshes the RadWindow --  GetRadWindow() goes null.  This is a problem, because now I cannot close the Window!  

Any ideas on how to persist or re-initiate the RadWindow object so that I can close my popup? 

6 Answers, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 16 Jan 2013, 06:06 PM
As is the case when I post these things I typically find the answer shortly after:

window.parent.GetRadWindow() returns the reference I need in this case.
0
John
Top achievements
Rank 1
answered on 15 Mar 2013, 12:15 AM
Hi There
I am about to start trying to do exactly what you are doing.  Any chance on getting the code which looks for that refresh and picks out the query string?

Thanks
0
Dan
Top achievements
Rank 1
answered on 15 Mar 2013, 12:24 AM
The 3rd party page let's me hand in a ReturnURL = so I hand in something like page.aspx?return=1 - then on Page Load I check for that value in the querystring.  If it is there I handle the post payment process.  Otherwise I prompt for payment.
0
John
Top achievements
Rank 1
answered on 15 Mar 2013, 12:55 AM
OK so the post back page is some kind empty unauthenticated page on your web site that looks for a key in the url to finish off processing and then closes it's parent window if finished?
0
Dan
Top achievements
Rank 1
answered on 15 Mar 2013, 01:42 AM
yes, that is basically it.  The magic is the Return URL that I set - which in my case calls the same page again but with a Querystring parameter that indicates the post process...  My code for that part looks something like this

Protected Overrides Sub Page_Load(ByVal isPostBack As Boolean)
    If Not Page.IsPostBack Then
        If Request.QueryString("returned") = "1" Then
            Dim Success As Boolean = CBool(Request.Params("Success"))
            Dim Action As String = HttpUtility.UrlDecode(Request.Params("Action"))
            Dim Message As String = HttpUtility.UrlDecode(Request.Params("Message"))
            Dim Status As String = HttpUtility.UrlDecode(Request.Params("Status"))
            Dim TransactionId As String = HttpUtility.UrlDecode(Request.Params("TransactionId"))
            Dim Errors As String = HttpUtility.UrlDecode(Request.Params("Errors"))
            Dim CardOnFileId As String = HttpUtility.UrlDecode(Request.Params("CardOnFileId"))
            If Success And TransactionId <> "" Then
                ' Success
                ScriptManager.RegisterStartupScript(Page, Page.GetType, "transactionComplete", "$(function(){ returnedData(true,'" & TransactionId & "') });", True)
                Exit Sub
            Else
                Dim eMessage As New StringBuilder
                With eMessage
                    .Append("<p>Error.   The following information was returned from the Credit Card Processor:</p>")
                    .Append("<ul>")
                    .Append("<li>Success: " & Success & "</li>")
                    .Append("<li>Action: " & Action & "</li>")
                    .Append("<li>Message: " & Message & "</li>")
                    .Append("<li>Status: " & Status & "</li>")
                    .Append("<li>TransactionId: " & TransactionId & "</li>")
                    .Append("<li>Errors: " & Errors & "</li>")
                    .Append("</ul>")
                End With
                ScriptManager.RegisterStartupScript(Page, Page.GetType, "ErrorSaving", "$(function(){ returnedData(false,'" & eMessage.ToString() & "',null,null,'Error',null) });", True)
            End If
        Else
 
            Dim qstring As New StringBuilder
            With qstring
                .Append(System.Configuration.ConfigurationManager.AppSettings("ProcessorPath").ToString())
                .Append("?Bank=" & Bank)
                .Append("&TransType=" & TransType)
                .Append("&CurCode=" & CurCode)
                .Append("&PageLoc=" & PageLoc)
                .Append("&Module=" & ElanModule)
                .Append("&SaveAsCOF=" & SaveAsCOF)
                .Append("&LoadCardTypes=" & LoadCardTypes)
                .Append("&ShowCSC=" & ShowCSC)
                .Append("&RequireCSC=" & RequireCSC)
                .Append("&PayeeNameId=" & PayeeNameId)
                '.Append("&ResultPostURL=" & Request.Url.AbsoluteUri.Split("?")(0) & "?returned=1")
                If Request.QueryString("returned") Is Nothing Then
                    .Append("&ResultPostURL=" & HttpUtility.UrlEncode(Request.Url.AbsoluteUri & "&returned=1"))
                Else
                    .Append("&ResultPostURL=" & HttpUtility.UrlEncode(Request.Url.AbsoluteUri))
                End If
                .Append("&ExpMonth=" & ExpMonth)
                .Append("&ExpYear=" & ExpYear)
                .Append("&IssueNum=" & IssueNum)
                .Append("&BillAdd1=" & BillAdd1)
                .Append("&BillAdd2=" & BillAdd2)
                .Append("&BillCity=" & BillCity)
                .Append("&BillState=" & BillState)
                .Append("&BillZip=" & BillZip)
                .Append("&BillCountry=" & BillCountry)
                .Append("&Phone=" & Phone)
                .Append("&Email=" & Email)
                .Append("&CardType=" & CardType)
                .Append("&StartMonth=" & StartMonth)
                .Append("&StartYear=" & StartYear)
                .Append("&CardOnFileId=" & CardOnFileId)
                .Append("&Amt=" & Amt)
                .Append("&ResultTarget=" & ResultTarget)
                .Append("&WebUserId=" & WebUserID)
                .Append("&CardName=" & CardName)
                .Append("&ModuleRefId=" & ModuleRefId)
            End With
            ccIframe.Attributes("src") = qstring.ToString()
 
        End If
    End If
End Sub

The I basically clean up and head back to the parent in Javascript

function returnedData(success, data)
{
    var oArg = new Object();
    oArg.success = success;
    oArg.data = data;
    window.parent.GetRadWindow().close(oArg);
}
0
John
Top achievements
Rank 1
answered on 15 Mar 2013, 01:45 AM
Thanks much appreciated
Tags
Window
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
John
Top achievements
Rank 1
Share this question
or