Submit HTML Form from ASP.NET Page

I need to submit an HTML form from an ASP.NET page. The HTML form post is necessary to integrate with another website (it is the only way they offer to integrate).

This is a problem, obvioulsy, because I can't have nested forms... and ASP.NET creates an all-encompasing form on its page.

I have to use an asp:imagebutton for my submit button. I tried changing the PostBackURL to the submit location on the other site, but this doesn't do anything for FireFox... only IE.
<asp:ImageButton id="submitButton" CssClass="submitButton" ImageUrl="~/images/submitButton.gif" runat="server" PostBackUrl="https://www.otherwebsite.com/submit" />

I don't mind doing this in code (read the controls and code a form post) or any other way you can get this to work propertly.

Thank you.
rcoastAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Salim FayadCommented:
Use the Server.Transfer
0
rcoastAuthor Commented:
How?
0
Salim FayadCommented:
Instead of using:
     Response.Redirect(url)
Use:
     Server.Transfer(url)
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

rcoastAuthor Commented:
I don't think I understand.

I have to insert an HTML form in my ASP.NET page. When the ASP:ImageButton is pressed, I have to submit the HTML form to a page outside of my server (FORM POST).

I don't know how to do this in ASP.NET because ASP.NET has one encompasing form and I can't put another in it.

I have no code yet. I don't know what to do.

I think your response of using "Server.Transfer(url)" is the last piece of code that I need, but I don't know what the rest of it should be.
0
Salim FayadCommented:
Here is how you should do it:
1. Put 1 form that has runat="server"
2. The second form without the runat="server"
3. In the second form put:
     a. In the action: the url where you want to post your method
     b. In the method: put "post"
4. Inside the second form, you should put html controls only, and in order to submit your data, you have to use the "<input type='submit'/>" html control
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
    <form id="form2" action="default.aspx" method="post">
       <input type="submit" value="Submit" />
    </form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcoastAuthor Commented:
In the example you give me, the second, HTML form is AFTER the ASP.NET standard form.

I can't do that, I can only put it inside (I think). If I put i outside, it won't be placed correctly on the page. Right?

What I think I need to do is combine the HTML form into the ASP.NET form, and write code (server side) to programatically do the POST that the HTML form required.

But... I don't know how to do that.

Am I right?
0
Salim FayadCommented:
No, you can do that, and it will be under the Server form. Anyway, try it and if it didn't work, send me your code.

Note, if you want to do the POST in the server code, then you have to use the Server.Transfer
0
rcoastAuthor Commented:
I haven't tried this yet... but I will tomorrow. Thanks for your patience.
0
rcoastAuthor Commented:
I havne't finished, but this solution satisfies me for now. Thank you.
0
rcoastAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.