2010-04-27 26 views
4

我在我的註冊頁面中有以下代碼轉到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

http://stackoverflow.com/a/3178668/1395178 – DevT 2014-01-13 09:10:29

回答

6

主網頁顯示,ContentPlaceHolder1是ASP.NET RUNAT =「服務器」的形式裏面,所以你不會能夠把裏面的貝寶形式該地區。您需要對其進行排序,以便PayPal表單不在任何其他表單內。

在這裏找到一個可能的解決方案:http://www.codersbarn.com/post/Solution-to-ASPNET-Form---PayPal-Problem.aspx但我不認爲你可以在禁用表單呈現的任何頁面上發生任何回發事件。

+0

它不影響回發,因爲你所做的只是切換表單。通常,這是在提交交易時完成的:-) – IrishChieftain 2010-10-14 19:25:17

0

您是否通過PayPal API integration示例,this sample might幫助。

+0

http://www.codersbarn.com/post/Solution-to-ASPNET-Form-PayPal-Problem.aspx表明PayPal SDK可能不適用於ASP。 NET 2。 – 2010-04-27 16:46:39

0

地方</form>結束標記就在第一個PayPal按鈕<form>行之前。
這爲我工作

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

1

我的首選解決方案是通過Javascript進行修復。

正如其他答案所述,問題在於PayPal按鈕的形式嵌入在.Net表單中,阻止PayPal表單提交到正確的位置。

要解決此問題,可以刪除PayPal表單元素,並且可以使用Javascript將.Net表單的操作更改爲指向PayPal,然後單擊提交。

以下變化需要作出的原代碼:

  • 的<形式>標籤已被刪除
  • 輸入提交形象改變爲「IMG」標籤
  • 一個onclick已被添加到主圖像中,首先將表單動作更改爲指向貝寶,然後提交表單。
  • '光標:指針' 風格已被添加到保持按鈕

所得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"> 
+0

當嘗試通過WYSIWYG編輯器添加PayPal按鈕時,此方法非常有用,其他解決方案在此實例中不可用。 – Radderz 2014-04-10 23:26:43

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>