I have a standard aspx page with which I need to add another standard HTML form into and have it submit to another location (external site), however whenever I press the submit button the page seems to do a post back rather than using the sub-forms action url.
A mock up of what the form relationships is below. Note in the real deployment the form will be part of a content area of a master page layout, so the form needs to submit independantly from the master page form.
<html xmlns='http://www.w3.org/1999/xhtml' > <head runat='server'> <title>Untitled Page</title> </head> <body> <form id='form1' runat='server'> <div> <form id='subscribe_form' method='post' action='https://someothersite.com' name='em_subscribe_form' > <input type='text' id='field1' name='field1' /> <input id='submitsubform' type='submit' value='Submit' /> </form> </div> </form> </body> </html>
It’s an interesting problem. Ideally you only want the 1 form tag on the page as other users have mentioned. Potentially you could post the data via javascript without having 2 form tags.
Example taken from here, modified for your needs. Not 100% sure if this will work for you but I think this is how you’ll have to approach it.
If javascript is not a viable option – you can use .Net’s HttpWebRequest object to create the post call in code behind. Would look something like this in the code behind (assuming your text field is an asp textbox: