Reputation: 1508
I have an asp.net page in 3.5 that I have a pay pal button on but when I click on the button it just refreshes the page. I think I need to encapsulate the paypal button in something so it is not trigging the refresh but goes to pay pal.
Anyone know a solution? Can I use an updatePanel or iframe?
Upvotes: 3
Views: 1815
Reputation: 47144
I would recommend you to use the PayPal Developer Toolkit for this. They're having a lot of good code samples and how to implement PayPal the best in your ASP.NET page.
Upvotes: 0
Reputation: 2638
I had this same issue once, I just used the following code for my button:
<asp:ImageButton ID="btnPayNow" runat="server" ImageUrl="~/images/Purchase/payNowButton.jpg" PostBackUrl="https://www.paypal.com/cgi-bin/webscr"/>
Hope that helps!
Upvotes: 4
Reputation: 4992
Paypal pay now buttons as generated by paypal site have their own form tags in. ASP.Net pages are generated with the whole page within a form, so you now have a form within a form which wont work. If you opt for a paypal hosted button you can have code like this within the asp.net page which will work:-
<input type="hidden" name="cmd" value="_s-xclick"/>
To order the item name for £99
<input type="hidden" name="hosted_button_id" value="note to programmer-this value is generated by paypal"/>
<asp:ImageButton ID="Button2" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" ImageAlign="AbsBottom" />
I know this is an old question, but I hope this helps someone else.
also, take a look here for a discussion of the issues and other possibe solutions. http://www.blackbeltcoder.com/Articles/ecommerce/quick-and-dirty-buy-now-buttons-in-asp-net
Upvotes: 2