How to include multiple <forms> on one ASP.NET page

  • Thread starter Thread starter Ben Turner
  • Start date Start date
B

Ben Turner

Hi,

I need to create an ASPX page that includes both traditional HTML Forms
(which are submitted to a third-party site like a travel booking service)
and also make use of the ASP.Net form. I've tried a number of approaches so
far but none seem to really suffice:

1. Position the HTML form elements absolutely and simply write the HTML
after the </form> tag. This sort of works but then allows no server control
over the creation of the form (i.e. setting the check-in date as today + 7)
as all of the elements lack the 'runat=server' parameter.

2. Make the HTML form submit to my IIS server and then simply prepare
redirect to a URL with all of the form elements included (i.e. mimic a
method=get form). This works (in some cases) but creates the most hideous
URL's (and obviously is limited in length etc. etc. etc.)

3. Submit the HTML form to my IIS server and then construct a POST query by
hand. I'm not even sure if this is allowed, and seems like a nasty approach
as it will involve unnecessary extra visits to my server.

What I'd really like to do is have the secondary form as a custom Web
Control so that it can be prepared at the server, customised according to
dates etc. and then served to whichever page needs it. When the user clicks
'submit' it would (preferably) submit directly to the third-party site.

Does anyone have any ideas?

Thanks in advance!

Ben.

mailto:[email protected]
 
If you are submitting the form using a button named Button1, you can
add the following code to Page Load event to submit your form directly
to Hotmail site.

Button1.Attributes.Add("onClick",
"Form1.action='http://www.hotmail.com';Form1.Submit;")

You don't need to create a custom control to submit a server form to a
third party site.

Thanks
Ram
 
Back
Top