ASP.Net WebForms + Paypal Form

女生的网名这么多〃 提交于 2019-12-11 09:36:58

问题


I am currently trying to integrate PayPal into our existing Web Application.

The Web Application is using ASP.NET WebForms.

Since in WebForms we have a form element around (almost) everything, I wonder how to integrate a PayPal Button which uses a form itself.

Is there any way to do it?


回答1:


Yes. I do it in a three step process:

  1. Remove the form tag from the PayPal code since you can't have nested forms.
  2. Add an ID, class, or something to the PayPal button to let you find it in a jQuery function (this example uses an id of paypalbutton).
  3. Add a jQuery script to catch the click and override the form post:

This may need to be modified to work with your specific code (but it may work as is):

$(document).ready(function() {
    $("#paypalbutton").on("click",function(n) {
        n.preventDefault();
        $("#aspnetForm").attr("action","https://www.paypal.com/cgi-bin/webscr");
        $("#aspnetForm").submit(); //or whatever your WebForms form element is called
    });
});


来源:https://stackoverflow.com/questions/26018625/asp-net-webforms-paypal-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!