4

我的注册页面中有以下代码可以转到贝宝按钮。但是当我单击按钮时,它只会刷新页面。

他们是我缺少的东西吗?我应该能够在 aspx 页面上包含一个贝宝按钮,对吗?

    <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>
4

6 回答 6

6

母版页显示 ContentPlaceHolder1 位于 ASP.NET runat="server" 表单内,因此您无法将 PayPal 表单放置在该区域内。您需要对其进行排列,以使 PayPal 表单不在任何其他表单内。

在这里找到一个可能的解决方案:http: //www.codersbarn.com/post/Solution-to-ASPNET-Form---PayPal-Problem.aspx但我认为你不能有任何回发事件禁用表单呈现的任何页面。

于 2010-04-27T16:17:51.783 回答
1

我首选的解决方案是通过 Javascript 进行修复。

正如其他答案所述,问题在于 PayPal 按钮的表单嵌入在 .Net 表单中,从而阻止了 PayPal 表单提交到正确的位置。

为了解决这个问题,可以删除 PayPal 表单元素,并且可以使用 Javascript 将 .Net 表单的操作更改为指向 PayPal,然后单击提交。

需要对原代码进行以下修改:

  • <form> 标签已被删除
  • 输入提交图像已更改为“img”标签
  • 主图添加了一个onclick,首先将表单动作更改为指向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">
于 2014-04-10T23:15:39.020 回答
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>
于 2016-03-10T17:53:32.787 回答
0

您是否浏览过PayPal API 集成示例,此示例可能会有所帮助。

于 2010-04-27T16:33:18.040 回答
0

</form>结束标签放在第一个 PayPal 按钮<form>行之前。
这对我有用

于 2012-09-29T21:55:19.090 回答
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" />

能够使用图像按钮解决此问题。有关更多详细信息,请参见此处

于 2014-01-13T09:39:19.917 回答