views:

81

answers:

4

Hi, in a content page of an asp.net web page, i would like to include the "paypal" button "Pay Now".

So, i've a master page, and a content page. In my content page i copy-paste paypal code. In particular i use a "modalpopupextender" to permit my user to buy the object. The problem is... it not work. So my hypotheses are:

  1. I'm not sure, but i think i can't use a nested <form action>
  2. If not the first, maybe i can't use a <form action> into a modal popup ?

someone can suggest me an "elegant" solutions to solve this ? Thank you ...

EDIT: in particular, what i'm trying to do is to permit to sell from a website. I've a master page, and a content page. Obviously in master page i've the classical "form action" . Then i'm gone to paypal and got this code: "

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<table>
<tr><td>
    <input type="hidden" name="on0" value="Annuncio Premium">Annuncio Premium
</td></tr>
<tr><td>
    <select name="os0">
        <option value="Premium 1">Premium 1 €1,00</option>
    </select>
</td></tr>
</table>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="encrypted" value="-----BEGIN ">
<input type="image" src="https://www.paypal.com/it_IT/IT/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - Il sistema di pagamento online più facile e sicuro!">
<img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1">
</form>

So i've pasted it into my content page ... as it... without changing. In particular i've pasted it, into a panel, that will show whith a "modalpopupextender". It works. But what it not work is when i click the paypal "Buy Now" button. My web page don't redirect to paypal, modalpopup disappears and nothing happens.

+2  A: 

You are quite correct, in that you cannot nest <form>s.

Nor can you use the form action to create a popup - the action attribute is the url to which the form posts to.

You can, however, have many <form>s on the page, so long as they are not nested. Perhaps that will solve you issue.

Can you please describe exactly what you are trying to achieve? It is not clear from your question what the problem is.

Oded
A: 

You are right in your first hypothese, you can't have nested form tags in a page.

You just have to put the code for the popup outside the form, you can have any number of forms in the page as long as they are not nested.

Guffa
+1  A: 

If I understand the question correctly, you are trying to create a dynamic HTML popup window which contains a PayPal form. You are having problems because the popup contains a form, but the HTML for the popup is already contained within a form.

If the problem you are experiencing is what I described above, the solution is fairly simple. You need to move all of the HTML for the popup outside of the exiting form element. If you are using CSS to properly lay out your site, it should be possible to display your dynamic popup wherever you need to on the page using relative or absolute positioning. The HTML for the popup need not be contained within another form. It may also be possible (perhaps even necessary) to put the contents of the popup into an iframe, which can be submitted entirely independently from the rest of the page. The semantics of how your popup works would depend on how you need your page to function.

So, to be clear...it is not possible to nest form elements. However, it is also not necessary to accomplish your needs.

EDIT:

To improve the answer above in light of the updated question. You can have multiple content panels on a master page. It should be entirely possible to create another content panel that is outside of your form element in your master page...and place your modal popup inside of this alternative content panel. My above answer would then still apply, as you no longer have nested forms.

jrista
hi Jrista. You're right ... but unfortunately my problem still remain. This because: 1. if i want to use the "modal popupextender", i can do only if i insert my extender between a "form runat=server" . But if i do this i get the error "only one form runat=server per page" (i double form runat server, the first from master page, the second for paypal button)... mmm this is an annoying problem...
stighy
@stighy: It should be possible to create a dynamic popup using just CSS and Javascript (I recommend JQuery or Mootools.) You are not limited to using only ASP.NET extenders to achieve a dynamic web site. There are LOADS of resourced on the net that explain how to create modal dynamic popups with JQuery...I highly recommend looking into them.
jrista
+1  A: 

Hi stighy

I had this exact issue too and couldn't believe that PayPal had not provided some sort of solution for .NET developers!!

Here is how I solved it:

<asp:ImageButton ID="btnPayNow" runat="server" ImageUrl="myPayPalButton.jpg" 
 PostBackUrl="https://www.paypal.com/cgi-bin/webscr" OnClick="btnPayNow_Click"/>

Use an ImageButton or normal button and simply remove the form tags for the PayPal code, leave in the hidden input fields and the data will be posted to the PayPal url!

Nice and easy :)

Ps. The method 'btnPayNow_Click()' does nothing, signature exists but there is no logic in the code I have.

Dal
it's EXACTLY what it solved my problem... Thank you and thanks a lot to other answer... they are ALL correct ...
stighy