Showing results for 
Search instead for 
Did you mean: 

CIM: iFrame appearing then disappearing

I'm using VS2010 to develop 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" "">

<html xmlns="">
<head runat="server">
    <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" />
    <script type="text/javascript">
        // 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 instead of
        AuthorizeNetPopup.options.useTestEnvironment = true;
    <form id="form1" runat="server">
        <button onclick="AuthorizeNetPopup.openManagePopup()">Manage my payment and shipping information</button>
    <form method="post" action="" 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==" />
    <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 class="AuthorizeNetPopupInner">
            <iframe name="iframeAuthorizeNet" id="iframeAuthorizeNet" src="contentx/empty.html" frameborder="0" scrolling="no"></iframe>
          <div class="AuthorizeNetPopupBottom">
            <div class="AuthorizeNetPopupLogo" title="Powered by Authorize.Net"></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 id="divAuthorizeNetPopupScreen" style="display:none;"></div>



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

Public Class TestPage
    Inherits System.Web.UI.Page
    Dim API_URL = ""

    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
            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
            End If
        End If
    End Sub
End Class



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.


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.