Submitting a form in ASP.NET from ServerSide
-
I have a submit button on a page called orderconfirm.aspx. When I click that button I am trying to send an e-mail and then redirect to paypal's payment form. There are some hidden objects on the the page that contain the data that paypal needs to complete the transaction. But when I view source in the page, the form's action is posting back to itself:
The serverside function is private void submit_Click(object sender, System.Web.UI.ImageClickEventArgs e) { SendEMail(); Response.Redirect("https://www.paypal.com/cgi-bin/webscr"); } Obviously this doesn't help me because I'm not actually posting the data, i'm just switching pages. Is there any way to change the action on the form from the server-side and/or submit the form from the server-side after I send the e-mail. Or maybe I should be taking a different approach...send the e-mail from the client-side? Help please.
-
I have a submit button on a page called orderconfirm.aspx. When I click that button I am trying to send an e-mail and then redirect to paypal's payment form. There are some hidden objects on the the page that contain the data that paypal needs to complete the transaction. But when I view source in the page, the form's action is posting back to itself:
The serverside function is private void submit_Click(object sender, System.Web.UI.ImageClickEventArgs e) { SendEMail(); Response.Redirect("https://www.paypal.com/cgi-bin/webscr"); } Obviously this doesn't help me because I'm not actually posting the data, i'm just switching pages. Is there any way to change the action on the form from the server-side and/or submit the form from the server-side after I send the e-mail. Or maybe I should be taking a different approach...send the e-mail from the client-side? Help please.
A popular way to do it in ASP.NET is to use Server.Transfer. This will transfer the execution of the page to the URL specified. It has the same effect of posting or submitting the form to that page, as with the action attribute on the form. One thing you should be careful of though, is to not put anything in the output stream, like Response.Write, before your call to Server.Transfer, because this output will be output in the new page. hope this helps, sivilian
-
A popular way to do it in ASP.NET is to use Server.Transfer. This will transfer the execution of the page to the URL specified. It has the same effect of posting or submitting the form to that page, as with the action attribute on the form. One thing you should be careful of though, is to not put anything in the output stream, like Response.Write, before your call to Server.Transfer, because this output will be output in the new page. hope this helps, sivilian
-
Thanks for the suggestion, but server.transfer will only submit to other .aspx pages. I'll have to try something else. Anyone else have any ideas?
Server.Transfer will work in this scenario. server.transfer("URL",boolean) I am not sure about the boolean value to be 'true' or 'false' to send the values to the redirecting page. check for appropriate option. or This is lengthy approach. feel really very long then ignore. create a aspx page and take all the values sent from the redirected page and build tags in the same manner how paypal needs and page onload write a javascript function to submit the form to paypal. make sure the form tag in the new page is not runat server. ... any doubt plz let me know....
-
I have a submit button on a page called orderconfirm.aspx. When I click that button I am trying to send an e-mail and then redirect to paypal's payment form. There are some hidden objects on the the page that contain the data that paypal needs to complete the transaction. But when I view source in the page, the form's action is posting back to itself:
The serverside function is private void submit_Click(object sender, System.Web.UI.ImageClickEventArgs e) { SendEMail(); Response.Redirect("https://www.paypal.com/cgi-bin/webscr"); } Obviously this doesn't help me because I'm not actually posting the data, i'm just switching pages. Is there any way to change the action on the form from the server-side and/or submit the form from the server-side after I send the e-mail. Or maybe I should be taking a different approach...send the e-mail from the client-side? Help please.
If you're trying to bypass paypal's confirm button, you're out of luck. http://www.knowledgegeek.com - Come on! I need the Traffic!