Invalid Postback or CallBack for Payment Gateway form

Can anybody help me sort out why I am always getting this error
I've already tried to everything I have researched about this error,
but not getting anywhere yet.
Some thing needs tweaking. Can you advise ?

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.]
   System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +261
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +83
   System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +89
   System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +36
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +479
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2549

The page looks like this

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="BuyMorePoints.aspx.vb" Inherits="SecureUser_BuyMorePoints" title="Untitled Page"   %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<h3>Buy More Points</h3>

    <p align=center>
        Purchase here by credit card using DirectOne secure payment gateway
    <br />
    Select the button for the amount /points required
    </p>
   
    <p align=center>
    <asp:DropDownList ID="DropDownList1" runat="server" >
        <asp:ListItem Value="20">2000 points for $20</asp:ListItem>
        <asp:ListItem Value="50">5000 points for $50</asp:ListItem>
        <asp:ListItem Value="100" Selected="True">10000 points for $100</asp:ListItem>
        <asp:ListItem Value="300">30000 points for $300</asp:ListItem>
    </asp:DropDownList>
    </p>
     
    <br />

<form name=form1 method=POST
action="https://vault.safepay.com.au/cgi-bin/test_payment.pl">
 
  <table width="800" border="0" align="center">
     
    <tr>
      <td>
        <input type=Hidden name=vendor_name value=businessname>
        <input type=Hidden name=currency value=$>
      </td>
    </tr>
 </table>
 
 <table align="center">
    <tr>
      <td>Name: </td>
      <td>
        <input type=Text name=Name size=30>
      </td>
    </tr>
   
    <tr>
      <td>Address Line 1: </td>
      <td>
        <input type=Text name=Address size=30>
      </td>
    </tr>
   
    <tr>
      <td>Address Line 2: </td>
      <td>
        <input type=Text name=Address2 size=30>
      </td>
    </tr>
   
    <tr>
      <td>City: </td>
      <td>
        <input type=Text name=City size=30>
      </td>
    </tr>
   
    <tr>
      <td>State: </td>
      <td>
        <input type=Text name=State size=30>
      </td>
    </tr>
   
    <tr>
      <td>Zip / Postal Code: </td>
      <td>
        <input type=Text name=Zip size=30>
      </td>
    </tr>
   
    <tr>
      <td>Country: </td>
      <td>
        <input type=Text name=Country size=30>
      </td>
    </tr>
   
  </table>
 


  <table width="500" border="5" align="center">
    <tr>
      <td align=CENTER>Amount to be paid:</td>
      <td align=CENTER>$<input type=Text name=Account_Payment value=DropDownList1.SelectedValue size=10>
      </td>
    </tr>
  </table>
 
  <p align=center>
 <!--
-------------------------------------------------------------------------------
 these fields will appear on the invoice as general information about
the customer, examples would be their name, address, contact number, email, and so
on.
--------------------------------------------------------------------------------
-->
 <input type=Hidden name=information_fields  
 value="Name,
        Addr1,
        Addr2,
        Addr3,
        City,
        State,
        PostCode,
        Country">
 <!--
-------------------------------------------------------------------------------
 If you want the information from a field to appear on the invoice but
don't want the actual field name (as it was specified on your form) to also
appear, you can tell the invoice generating script to suppress the field name while
printing the field data.

--------------------------------------------------------------------------------
    <input type=Hidden name=suppress_field_names value="Address2,
        City,
        State,
        Zip,
        Country">
 -------------------------------------------------------------------------------
 If a field is specified as required, it must be filled out by the
customer or the  invoice page will not be generated.

--------------------------------------------------------------------------------
 <input type=Hidden name=required_fields   value="Address,
        City,
        State,
        Zip,
        Country,
        Account_Payment">

-------------------------------------------------------------------------------
 these are fields that are present on the order form (to calculate the
subtotal  that gets sent to DirectOne, but they are not actually wanted on the
form.  Specifying them in this section means the invoice generating script
will ignore  both the field name, and the field data

--------------------------------------------------------------------------------
-->
    <input type=hidden name=gst_rate value=10>
    <input type=Hidden name=print_zero_qty value=false>
   
    <input type=Reset value=Clear>
    <input type=Submit value=Submit>
   
</form>

  <div align="center"><font face="Arial, Helvetica, sans-serif">When you press SUBMIT you will be taken to the secure payment page.<i><b></b></i></font></div>
 
  <p align=center>
  <A HREF="http://www.directone.com.au/html/vendor_link.html"/>
                      <img src="http://www.directone.com.au/images/safe_link.gif"; BORDER=0>
  </p>

    <br/>
</asp:Content>

Ths code behing looks like this

Partial Class SecureUser_BuyMorePoints
    Inherits System.Web.UI.Page
   


    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

        ClientScript.RegisterForEventValidation("DropDownList1", "2000 points for $20")
        ClientScript.RegisterForEventValidation("DropDownList1", "5000 points for $50")
        ClientScript.RegisterForEventValidation("DropDownList1", "10000 points for $100")
        ClientScript.RegisterForEventValidation("DropDownList1", "30000 points for $300")

        MyBase.Render(writer)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack Then
            DropDownList1.DataBind()
        Else
            DropDownList1.DataBind()
        End If
    End Sub
End Class

 
jaffacatAsked:
Who is Participating?
 
McExpConnect With a Mentor Commented:
I believe your DropdownList needs to be on a form with runat="server" set. If you have a form in your master page you can't nest another form inside it.

Would you be happy to turn off event validation. you could do it just for this page.
0
 
jaffacatAuthor Commented:
Prefer not to turn it off, because it's supposed to be for security purpose to validate the form.
I will try to remove this page from the masterpage and see how it goes, and add add runat="server"
0
 
jaffacatAuthor Commented:
Hi ... me again
A different problem this time. I have put the new page below, but now when I press submit, it doesn't go off to the DirectOne payment webpage, but postback to my page again clearing the form, apparently having dome nothing. Can you tell why it's doing this ? Also another question ,,, can I get the selected value of the dropdownlist to populate the amount to be paid. The way I'm doing it now doesn't work.
Thanks for your help

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="BuyMorePoints.aspx.vb" Inherits="SecureUser_BuyMorePoints" %>

<!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>Untitled Page</title>
</head>
<body>
           
<form id="Form1" name=form1 method=POST runat="server" action="https://vault.safepay.com.au/cgi-bin/test_payment.pl">
 
  <h3>Buy More Points</h3>

    <p align=center>
        Purchase here by credit card using DirectOne secure payment gateway
    <br />
    Select the button for the amount /points required
    </p>
   
    <p align=center>
    <asp:DropDownList ID="DropDownList1" runat="server" >
        <asp:ListItem Value="20">2000 points for $20</asp:ListItem>
        <asp:ListItem Value="50" Selected="True">5000 points for $50</asp:ListItem>
        <asp:ListItem Value="100">10000 points for $100</asp:ListItem>
        <asp:ListItem Value="300">30000 points for $300</asp:ListItem>
    </asp:DropDownList>
    </p>
     
    <br />
 
  <table width="800" border="0" align="center">
     
    <tr>
      <td>
        <input type=Hidden name=vendor_name value=businessname>
        <input type=Hidden name=currency value=$>
      </td>
    </tr>
 </table>
 
 <table align="center">
    <tr>
      <td>Name: </td>
      <td>
        <input type=Text name=Name size=30>
      </td>
    </tr>
   
    <tr>
      <td>Address Line 1: </td>
      <td>
        <input type=Text name=Address size=30>
      </td>
    </tr>
   
    <tr>
      <td>Address Line 2: </td>
      <td>
        <input type=Text name=Address2 size=30>
      </td>
    </tr>
   
    <tr>
      <td>City: </td>
      <td>
        <input type=Text name=City size=30>
      </td>
    </tr>
   
    <tr>
      <td>State: </td>
      <td>
        <input type=Text name=State size=30>
      </td>
    </tr>
   
    <tr>
      <td>Zip / Postal Code: </td>
      <td>
        <input type=Text name=Zip size=30>
      </td>
    </tr>
   
    <tr>
      <td>Country: </td>
      <td>
        <input type=Text name=Country size=30>
      </td>
    </tr>
   
  </table>
 


  <table width="500" border="5" align="center">
    <tr>
      <td align=CENTER>Amount to be paid:</td>
      <td align=CENTER>$<input type=Text name=Account_Payment value=DropDownList1.SelectedValue size=10>
      </td>
    </tr>
  </table>
 
  <p align=center>
 <!--
-------------------------------------------------------------------------------
 these fields will appear on the invoice as general information about
the customer, examples would be their name, address, contact number, email, and so
on.
--------------------------------------------------------------------------------
-->
 <input type=Hidden name=information_fields  
 value="Name,
        Addr1,
        Addr2,
        Addr3,
        City,
        State,
        PostCode,
        Country">
 <!--
-------------------------------------------------------------------------------
 If you want the information from a field to appear on the invoice but
don't want the actual field name (as it was specified on your form) to also
appear, you can tell the invoice generating script to suppress the field name while
printing the field data.

--------------------------------------------------------------------------------
    <input type=Hidden name=suppress_field_names value="Address2,
        City,
        State,
        Zip,
        Country">
 -------------------------------------------------------------------------------
 If a field is specified as required, it must be filled out by the
customer or the  invoice page will not be generated.

--------------------------------------------------------------------------------
 -->
 <input type=Hidden name=required_fields   value="Address,
        City,
        State,
        Zip,
        Country,
        Account_Payment">
<!--
-------------------------------------------------------------------------------
 these are fields that are present on the order form (to calculate the
subtotal  that gets sent to DirectOne, but they are not actually wanted on the
form.  Specifying them in this section means the invoice generating script
will ignore  both the field name, and the field data

--------------------------------------------------------------------------------
-->
    <input type=hidden name=gst_rate value=10>
    <input type=Hidden name=print_zero_qty value=false>
   
    <input type=Reset value=Clear>
    <input type=Submit value=Submit>
   

    <p align=center>
        <font face="Arial, Helvetica, sans-serif">When you press SUBMIT you will be taken to the secure payment page.<i><b></b></i></font>
 
 
        <A HREF="http://www.directone.com.au/html/vendor_link.html"/>
                      <img src="http://www.directone.com.au/images/safe_link.gif"; BORDER=0>
    </p>
    <br/>
   
 </form>      
   
</body>
</html>


The code behind now looks like this

Partial Class SecureUser_BuyMorePoints
    Inherits System.Web.UI.Page

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

        ClientScript.RegisterForEventValidation("DropDownList1", "20")
        ClientScript.RegisterForEventValidation("DropDownList1", "50")
        ClientScript.RegisterForEventValidation("DropDownList1", "100")
        ClientScript.RegisterForEventValidation("DropDownList1", "300")

        MyBase.Render(writer)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim intZero As Integer
        If Page.IsPostBack Then
            intZero = 0
        Else
            DropDownList1.DataBind()
        End If
    End Sub

End Class
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.