How do I submit a form and then do a response.redirect?

T

Trevor Braun

Hi all. I'm really stuck here, and would greatly appreciate any help or
suggestions.

I'm trying to (from the server side) submit the page that is loading to a
new window, then redirect to another form.

What I'm trying to do would look like:

protected void Page_Load(object sender, EventArgs e)
{
form1.hiddenField1.Value = Request["ccvalue1"];
form1.hiddenField2.Value = Request["ccvalue2"];

form1.Target="_blank";
form1.Submit();

Response.Redirect("default.aspx");
}

The reason I'm doing this is because ASP.NET changes the ID's of hidden
fields that belong to a page with a master template, and I need to submit to
a credit card pay page that is expecting specially named hidden form fields.
This page is a dummy page (without a master template page) that receives
values from an order wizard then loads the values into the hidden fields on
the dummy page's load and submits itself to the credit card pay page in a
new window and then redirects itself to "default.aspx", the user's home
page.


Thanks again for any suggestions.
Trevor Braun
 
N

Neutrino

The strategy you are trying to implement would work but i might suggest
that you take a look at the HttpWebRequest class (net framework
System.Net). With an object of this class you can call the credit card
page submitting all the fields you need (with POST method) and get the
output returned by the credit card page. You would be able to do this
within the same page in your application (without the need of opening
another browser window).

You can find more information here:

http://www.netomatix.com/HttpPostData.aspx

and here

http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest(VS.80).aspx

Regards
 
N

Neutrino

The strategy you are trying to implement would work but i might suggest
that you take a look at the HttpWebRequest class (net framework
System.Net). With an object of this class you can call the credit card
page submitting all the fields you need (with POST method) and get the
output returned by the credit card page. You would be able to do this
within the same page in your application (without the need of opening
another browser window).

You can find more information here:

http://www.netomatix.com/HttpPostData.aspx

and here

http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest(VS.80).aspx

Regards
 
T

Trevor Braun

Thanks. That sounds like an excellent solution, but I don't know if will
fit what I need to do. The credit card information actually gets entered
into the new window, the only thing I submit to the pay page are three
hidden fields (two identify the company, the third holds the amount to be
charged to the card.)

I'll play around with it and see if I can't get something working.

Trevor Braun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top