This is a widespread question, but one of the possible answers is to create a second form that contains the necessary PayPal code.
This is a simplified example ; usually there is the logic necessary to achieve this goal. For example, if the buttons should be contained in the default form in ASP.Net, there must be server and / or client code to connect them to this second form to ensure that it contains the correct hidden values.
In your web form
<form id="form1" runat="server">
</form>
<%=base.GetMarkupOutsideDefaultForm() %>
In CodeBehind Code
public string GetMarkupOutsideDefaultForm()
{
StringBuilder sb = new StringBuilder();
sb.Append( "<form action=\"" + AppSettings.PayPalUrl + "\" method=\"post\" id=\"frmPayPal\" target=\"_blank\">" );
sb.Append( "</form>" );
sb.Append( "<script type=\"text/javascript\">document.forms[\"frmPayPal\"].submit();</script>" );
return sb.ToString();
}
If the logic is complex, the second block of code should really be contained in the helper class.
Hope someone goes the right way.
source
share