Developer Kinks
Developer Kinks

Reputation: 61

Paypal Form Tag issue in asp.net

Hello guys i have gatting issue on loading asp.net

i have using master page for sub pages there is a form tag in materpage i have add a paypal button in sub page which is this in master page form tag is also important

in masterpage <form id="form1" runat="server"></form>

and in sup age

 <form id="form2" runat="server" name="Paypal" action="https://www.paypal.com/cgi-bin
          /webscr"
              method="post">
              <input type="hidden" name="cmd" value="_cart" />
              <input type="hidden" name="upload" value="1" />
              <input type="hidden" name="business" value="
   <%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
    " />
  <input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>" 
       />
  <input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
  <input type="hidden" name="quantity_1" value="1" />
  <input type="hidden" name="currency_code" value="USD" />
  <input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
  <input type="hidden" name="lc" value="Stronger" />
  <input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
         payments with PayPal - it's fast, free and secure!"
           style="background: url(images/update-account.png);"/>
</form>

I'm getting bug this with sub page below

Server Error in '/Project' Application. A page can have only one server-side Form tag. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.

anybody have a idea how can i use form tag in sub page also.

Upvotes: 0

Views: 440

Answers (3)

user1390931
user1390931

Reputation: 53

If you'are under a MasterPage Don't use the form tag as long as you're inside a form, just delete it, delete the hidden input that causes the SUBMIT and, instead, use the following ImageButton:

<asp:ImageButton ID="cmdpay" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" Text=""  ImageUrl="images/paynow.png" ></asp:ImageButton>

It works

Upvotes: 0

Developer Kinks
Developer Kinks

Reputation: 61

Hi I have found this solution and its work solution is below:

<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
                                method="post" target="_blank"></form>
                                <form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
                                method="post">
              <input type="hidden" name="cmd" value="_cart" />
              <input type="hidden" name="upload" value="1" />
              <input type="hidden" name="business" value="
   <%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
    " />
  <input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>" 
       />
  <input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
  <input type="hidden" name="quantity_1" value="1" />
  <input type="hidden" name="currency_code" value="USD" />
  <input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
  <input type="hidden" name="lc" value="Stronger" />
  <input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
         payments with PayPal - it's fast, free and secure!"
           style="background: url(images/update-account.png);"/>
</form>

This code is working good as i want.

Upvotes: 0

Pawan
Pawan

Reputation: 1075

Please check how many <form> tags are written on your aspx/html page. Make sure you are not using masterpage for this page.

Upvotes: 1

Related Questions