My PayPal button will not link to payment. This only refreshes the page, why?

I have the following code on my registration page to go to the paypal button. But when I click on the button, it just refreshes the page.

Are they missing something for me? Should I enable the paypal button on the aspx page correctly?

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Panel runat="server" ID="pnlRegisterPage" CssClass="registerPage"> <table> <tr> <td><p>Plain text</p></td> <td> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="Z8TACKRHQR722"> <table> <tr><td><input type="hidden" name="on0" value="Registration Type">Registration Type</td></tr><tr><td><select name="os0"> <option value="Team">Team $80.00</option> <option value="Individual">Individual $40.00</option> </select> </td></tr> </table> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </td> </tr> </table> </asp:Panel> </asp:Content> 

Master page

 <body> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div class="masterbody"> <center> <asp:Image runat="server" ID="imgLogo" ImageUrl="" /></center> <div class="menubar"> <div class="loginview"> <asp:LoginView ID="MenuBar" runat="server"> <AnonymousTemplate> </AnonymousTemplate> <LoggedInTemplate> </LoggedInTemplate> </asp:LoginView> </div> </div> <div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </div> <div class="footer"></div> </form> </body> 
+4
source share
6 answers

The master page shows that ContentPlaceHolder1 is in the form of ASP.NET runat = "server", so you cannot place the PayPal form inside this region. You will need to change it so that the PayPal form is not inside any other form.

A possible solution found here: http://www.codersbarn.com/post/Solution-to-ASPNET-Form---PayPal-Problem.aspx , but I don’t think you can have any postback events on any page with disabling the form.

+6
source

My preferred solution is to make a fix through Javascript.

As indicated in other answers, the problem is that the PayPal button is embedded in the .Net form, preventing the PayPal form from sending to the right place.

To get around this, the PayPal form element can be removed, and Javascript can be used to change the action of the .Net form to point to PayPal, and then submit by click.

The following changes must be made to the source code:

  • <form> tags removed.
  • The input image of the sending has changed to the tag 'img'
  • Onclick is added to the main image, first changing the form's action to point to PayPal, and secondly by submitting the form.
  • Added cursor: pointer style to keep button look

PayPal Button Code Result:

 <input type="hidden" name="cmd" value="_s-xclick" <input type="hidden" name="hosted_button_id" value="xxxxxxxx"> <img style="cursor:pointer;" alt="PayPal – The safer, easier way to pay online." border="0" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" onclick="document.forms[0].action='https://www.paypal.com/cgi-bin/webscr';document.forms[0].submit();" /> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> 
+1
source
 Its simple, Just add another ContentPlaceHolder in mater page use this content place holder for paypal button. Like this: Master Page <body> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div class="masterbody"> <center> <asp:Image runat="server" ID="imgLogo" ImageUrl="" /></center> <div class="menubar"> <div class="loginview"> <asp:LoginView ID="MenuBar" runat="server"> <AnonymousTemplate> </AnonymousTemplate> <LoggedInTemplate> </LoggedInTemplate> </asp:LoginView> </div> </div> <div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </div> </form> <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"> </asp:ContentPlaceHolder> </body> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> past paypal button code here: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="Z8TACKRHQR722"> <table> <tr><td><input type="hidden" name="on0" value="Registration Type">Registration Type</td></tr><tr><td><select name="os0"> <option value="Team">Team $80.00</option> <option value="Individual">Individual $40.00</option> </select> </td></tr> </table> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </asp:Content> 
+1
source
0
source

Place the </form> end </form> in front of the first <form> button of the PayPal button.
It worked for me

0
source
 <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" /> 

You can solve this problem using the image button. see here for more details

0
source

Source: https://habr.com/ru/post/1308156/


All Articles