Site structure
Version 4.x > Site structure > Use of Forms tag in Kentico View modes: 
User avatar
Member
Member
phil-environmental-academy.co - 1/12/2010 3:50:27 AM
   
Use of Forms tag in Kentico
Hi, I hope this is the right forum for the question, sorry if it is not...

I have been informed that you cannot use the <form> tag in pages within in kentico since it already uses a surrounding form tag.

However, I would like to insert paypal "buy it now" buttons onto a certain page within my site. E.g:

<form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal">
<input type="hidden" value="_s-xclick" name="cmd" /> <input type="hidden" value="6856762" name="hosted_button_id" /> <input type="image" border="0" alt="PayPal - The safer, easier way to pay online." name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" /> <img width="1" height="1" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" alt="" />
</form>



After trying to insert this it does indeed affect the overall page, and the first form tag which appears within the editor never works correctly. Any subsequent form tags seem to work fine however.

Is there a solution to this?

User avatar
Member
Member
Alex Rybin - 1/12/2010 9:41:02 AM
   
RE:Use of Forms tag in Kentico
This is not Kentico restriction, this is ASP.NET restriction. :)

I think there is no way to solve this issue easy, without some javascript or C# coding.

Easiest way I see - use JavaScript. Something like this:

<form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal">
<input type="hidden" value="_s-xclick" name="cmd" /> <input type="hidden" value="6856762" name="hosted_button_id" /> <input type="image" border="0" alt="PayPal - The safer, easier way to pay online." name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" onclick="document.forms[0].action = 'https://www.paypal.com/cgi-bin/webscr';" /> <img width="1" height="1" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" alt="" />
</form>

Comments:
1. We remove <form> tags, we use main form.
2. On the click to button we change form's action link, so all form will be submitted to paypal.

:)

But may be you can use simple <a> and submit parameters in query?
Like this

<a href="https://www.paypal.com/cgi-bin/webscr?_s-xclick=cmd&hosted_button_id=6856762" target="paypal">PayPal</a>

User avatar
Member
Member
Planx - 1/12/2010 9:58:32 AM
   
RE:Use of Forms tag in Kentico
ahh thanks Alex

I'll have a play about and see what i can come up with :)

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/13/2010 3:05:54 AM
   
RE:Use of Forms tag in Kentico
Hi all,

Thanks Alex for this option. I have another suggestion and it is that you can use that code inside an IFRAME tag which will be inserted to the page.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
Planx - 1/13/2010 5:44:15 AM
   
RE:Use of Forms tag in Kentico
ahhh yes, thanks for the suggestion Jurajo.

I've just tried this and it seems to work fine!

Thanks to both of you for the help!


:)

Phil

User avatar
Member
Member
Alex Rybin - 1/13/2010 1:18:21 PM
   
RE:Use of Forms tag in Kentico
Hah... Forgot about iframes... :(

User avatar
Member
Member
michael-thefamousgroup.com - 1/24/2010 7:39:42 PM
   
RE:Use of Forms tag in Kentico
Hi

Would you be able to post the code you used to make it work? We are having the same issues and I'm not sure if we need to create a new page with the paypal button in and then import that page into the iframe.

Thanks
Michael

User avatar
Member
Member
Planx - 1/26/2010 4:17:43 AM
   
RE:Use of Forms tag in Kentico
Hi Michael,

I basically just made a seperate html page with the paypal buttons in etc then fed that page into an iframe with the following html in kentico:

<iframe width="98%" height="1400" frameborder="0" src="http://www.environmental-courses.com/file.php/1/shop/shop2.htm">
<p>Your browser does not support iframes.</p>
</iframe>


result:

http://www.environmental-academy.co.uk/Shop.aspx

User avatar
Member
Member
kentico_pavelk - 1/26/2010 5:34:44 AM
   
RE:Use of Forms tag in Kentico
Hello,

Thank you Planx for the example. I would proceed the same way.


Best regards,
Pavel Knotek

User avatar
Member
Member
charmc-mercola - 5/18/2011 3:17:11 AM
   
RE:Use of Forms tag in Kentico
Hi Guys!

Maybe you can make my life easier,

I need a <form> tag inside my template, and what if i dont want to use an iframe? what are my other options?

User avatar
Member
Member
kentico_michal - 5/19/2011 2:53:05 AM
   
RE:Use of Forms tag in Kentico
Hello,

Kentico CMS does not allow you to use several form tags on one page (only one is allowed).

If you would like to post data from your form control you can use one of following ways:
1. use iframe and insert the whole page code into it
2. use webclient class to post data instead of form control. You can find an example here: www.netomatix.com

So, you could create a custom web part using this code. How to create a custom web part is described here: Developing web parts.


Best regards,
Michal Legen