Is there a way to insert a form/simulated form with a post action to another URL?
The core of this problem is related to the kind a limitation of the ASP .NET itself where you aren't allowed to place nested 'form' elements on your page. We will explain the workaround for this problem on the following example.
You want to get a currency convertor calculator working (
www.xe.com/ucc/customize.php) but it relies on having a form with a post action set to a cgi page on their site.
There are two approaches.
1) You create a custom web part. Than simply copy & paste the HTML code of the XE Universal Currency Converter into the '.ascx' file. You need to remove the 'form' tag from the beginning of the HTML code and alter the original input HTML submit button with the ASP .NET button server control. In the '
Page_Load' event handler you then set the '
PostBackURL' for this button to
http://www.xe.com/ucc/convert.cgi . (Please find more information on web part development in "
Developing web parts" article)
Please note at the bottom of the page is attached an export of a simple XE UCC web part for the Kentico CMS 3.1. Once you import this web part you can find it in the '
Custom' category. Place it on your web site and set the '
URL' property representing the URL where the data should be post. Once the button is submitted the data should be posted and correctly processed by the target CGI page.
2) You create an ASPX template as described in "
Creating a new ASPX page template". You could simply place the HTML code of the XE UCC after the '
form' tag of the ASPX template. The limitation of this approach is that you aren’t able to combine the design of the page loaded into the original 'form' and combine it with the content of the XE UCC's 'form'.
See also: armsinfragilehands.blogspot.com/2008/04/post-with-input-parameters-in-aspnet.html
Web part packageApplies to: Kentico CMS 2.x, 3.x