我在注册页面中有以下代码转到paypal按钮。但是,当我点击按钮时,它只刷新页面。
他们缺少什么?我应该可以在aspx页面上包含一个paypal按钮吗?
<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>
母版页
<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>
答案 0 :(得分:6)
母版页显示ContentPlaceHolder1位于ASP.NET runat =“server”表单内,因此您无法将PayPal表单放在该区域内。您需要对其进行排序,以使PayPal表单不在任何其他形式内。
此处找到了一个可能的解决方案:http://www.codersbarn.com/post/Solution-to-ASPNET-Form---PayPal-Problem.aspx但我不认为您可以在禁用表单呈现的任何页面上进行任何回发事件。
答案 1 :(得分:1)
我首选的解决方案是通过Javascript进行修复。
正如其他答案所述,问题在于PayPal按钮的形式嵌入.Net表单中,阻止PayPal表单提交到正确的位置。
为了解决这个问题,可以删除PayPal表单元素,并可以使用Javascript将.Net表单的操作更改为指向PayPal,然后单击提交。
需要对原始代码进行以下更改:
生成的PayPal按钮代码:
<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">
答案 2 :(得分:1)
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>
答案 3 :(得分:0)
您是否完成了PayPal API integration示例this sample might帮助。
答案 4 :(得分:0)
在第一个PayPal按钮</form>
行之前放置<form>
结束标记
这对我有用
答案 5 :(得分:0)
<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" />
能够使用图像按钮解决此问题。有关详细信息,请参阅Here