How to get an ASP.NET 2.0 Content Form to submit to a third party web page

Posted on 2009-02-10
Last Modified: 2012-05-06

I'm a web app that uses Master pages.  Most of the pages use nested master pages. With master pages you must have a <form> tag with a runat=server attribute.  This causes the page to just post back to itself, works great.

However, I have 1 page in the whole site that needs to post to a third party page, and that page will read some of the controls I have on my page, then auto register someone (one of the fields is an email).

The issue I am having is how do I get the form to post to the third part page.

I've tried this on the Master Page:

<form id="Form1" method="post" runat="server" onsubmit="document.Form1.action='WebForm2.aspx';">

However, that gives me an error on the Form1 part as .NET gives the form some weird ID of aspnetForm. I tried chaning the Form1 part to that, but the page just hangs and does nothing.

I also tried this on the the onClick fo the submit button:

       function valSubmit()  
            var doc = document.forms[0];

I see the Hello alert box, but the form still posts back to itself.

Can I do this? I really want the web page to have the same look and feel (thus the Master pages), but it just doesn't seem to work.  if I remove the master pages, it works, but then the Look and Feel looks crappy.

Thanks in advance.
Question by:WaldaInc
    LVL 29

    Accepted Solution

    Hi WaldaInc,
    Try using post the form via button's PostBackUrl property
    <form id="Form1" method="post" runat="server">
    <asp:Button ID="btnSubmit" runat="server" PostBackUrl="" Text="  Submit  " /><

    Author Closing Comment

    Yep, I found that out too (page 5 of the Google search). Thanks for posting this, was going to close it tomorrow moring.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now