Reply
Member
Posts: 1
Registered: ‎10-06-2011

CIM: iFrame appearing then disappearing

[ Edited ]

I'm using VS2010 to develop asp.net pages for a customer ordering website.  I have included the example code into a test page but cannot get the iFrame to stay on the screen.  It appears when I press the "Manage" button but immediately disappears and the page does a postback to the server.

 

How do I get it to stay displayed to allow the user to see their data?

I have posted my code below

 

Thanks in advance.

 

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestPage.aspx.vb" Inherits="WebOrder.TestPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="contentx/manage.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="contentx/popup.js"></script>
    <!--[if lte IE 6]>
        <link href="contentx/manageIELTE6.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <script type="text/javascript">
    //<![CDATA[
        // Uncomment this line if eCheck is enabled. This does not affect functionality, only the initial sizing of the popup page for add payment.
        //AuthorizeNetPopup.options.eCheckEnabled = true;

        // Uncomment these lines to define a function that will be called when the popup is closed.
        // For example, you may want to refresh your page and/or call the GetCustomerProfile API method from your server.
        //AuthorizeNetPopup.options.onPopupClosed = function() {
        //	your code here.
        //};

        // Uncomment this line if you do not have absolutely positioned elements on your page that can obstruct the view of the popup.
        // This can speed up the processing of the page slightly.
        //AuthorizeNetPopup.options.skipZIndexCheck = true;

        // Uncomment this line to use test.authorize.net instead of secure.authorize.net.
        AuthorizeNetPopup.options.useTestEnvironment = true;
  //]]>
  </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button onclick="AuthorizeNetPopup.openManagePopup()">Manage my payment and shipping information</button>
    </div>
    </form>
    <form method="post" action="https://test.authorize.net/hosted/profile/manage" id="formAuthorizeNetPopup" name="formAuthorizeNetPopup" target="iframeAuthorizeNet" style="display:none;">
        <input id="hToken" runat="server"  type="hidden" name="Token" value="6ieEXvWhHWNJ/Uq7dNngFlVmb5uuD+ncZjrN3bWi0QTTxjwNuW/AYFQIFsTpI1coVJYsj2gpiWKkeXzRNGGeP3lg5jUxXdeO9KwpCNjMVKB75+9nbcM4/lKMzDQ+gaJgEnarscZ9lrQAJ8TKKrBnDjTHhbeqOfV6nIb1dJ8O77blV79+uMpmaqTePGCD07YSf+Hu8ZnOgtoY//dkSbpyeuT/nblgK0qchXY8ot8Vo5q1xcxDRMpdkFGeHPAhZsQEfOizdxOirMeMN8bajiI9oTMR1AKQXtAlGhrPQpuDqpfgVw2JQ2N1PNb/pclDNfMcmLAWbFuStTq9pxg8Dl7Zbw==" />
   </form>
    <div id="divAuthorizeNetPopup" style="display:none;" class="AuthorizeNetPopupGrayFrameTheme">
        <div class="AuthorizeNetPopupOuter">
          <div class="AuthorizeNetPopupTop">
            <div class="AuthorizeNetPopupClose">
              <a href="javascript&colon;;" onclick="AuthorizeNetPopup.closePopup();" title="Close"> </a>
            </div>
          </div>
          <div class="AuthorizeNetPopupInner">
            <iframe name="iframeAuthorizeNet" id="iframeAuthorizeNet" src="contentx/empty.html" frameborder="0" scrolling="no"></iframe>
          </div>
          <div class="AuthorizeNetPopupBottom">
            <div class="AuthorizeNetPopupLogo" title="Powered by Authorize.Net"></div>
          </div>
        </div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowT"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowB"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowL"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowTR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowBR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowBL"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowTL"></div>
    </div>    
    <div id="divAuthorizeNetPopupScreen" style="display:none;"></div>
</body>
</html>

 

 

Imports System.Data.OleDb
Imports System.Net
Imports System.IO
Imports System.Xml

Public Class TestPage
    Inherits System.Web.UI.Page
    Dim API_URL = "https://apitest.authorize.net/xml/v1/request.api"

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

        If Not IsPostBack Then
            Dim s As String = ""
            Dim asr As New AppSettingsReader
            Dim TranKey As String = asr.GetValue("TranKey", GetType(String))
            Dim APILogin As String = asr.GetValue("APILogin", GetType(String))
            Dim st As String = ""
            Dim ProfileID As String = GetCustomerProfileID("225", Session.SessionID)
            Dim x As String = ""
            Dim xn As XmlNode
            Dim xnl As XmlNodeList
            Dim Token As String = ""

            x = CreateGetHostedProfilePageRequest(ProfileID)
            
            ' send the request to the provider
            s = SendRequestToProvider(x)

            Dim xdoc As New XmlDocument
            xdoc.LoadXml(s)
            xnl = xdoc.GetElementsByTagName("resultCode")
            st = xnl.Item(0).InnerText
            If st = "Ok" Then
                hToken.Value = xdoc.GetElementsByTagName("token").Item(0).InnerText
                'Token = xdoc.GetElementsByTagName("token").Item(0).InnerText
            Else
            End If
        End If
    End Sub
End Class

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: CIM: iFrame appearing then disappearing

The only different from the sample code it that the

<button onclick="AuthorizeNetPopup.openManagePopup()">Manage my payment and shipping information</button>

is within a <form /> in your code but it is not in the sample code.

Member
Posts: 1
Registered: ‎01-06-2014

Re: CIM: iFrame appearing then disappearing

The problem is that the button is embeded in another form:

 

<button onclick="AuthorizeNetPopup.openManagePopup()">

After the onclick action finishes (which uses javascript to submits the formAuthorizeNetPopup form), the button's default action is to submit the form in which it is contained: and submitting that form will cancel submission of the first form.

 

The fix is to add the type="button" attribute and return false from the onclick handler, like this:

 

<button type="button" onclick="AuthorizeNetPopup.openManagePopup(); return false;">

 

See How to prevent buttons from submitting forms for further details.